c#中怎么打开一个查看文件路径的对话框

2024-11-30 13:00:12
推荐回答(2个)
回答1:

//添加一个 openFileDialog,
//单击button1时候的事件,name为文件名字,path为除了名字之外的路径
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
string name = Path.GetFileName(openFileDialog1.FileName);
string path = Path.GetDirectoryName(openFileDialog1.FileName);
}

回答2:

是openfiledialog控件嘛?