OpenFileDialog file = new OpenFileDialog();
使用file打选中一个文件后,怎么获取该文件在电脑上的存放路径呢?
file.FileName
OpenFileDialog file= new OpenFileDialog(); file.Filter = "Excel文件|*.xls|Excel文件|*.xlsx"; file.InitialDirectory = Application.StartupPath; file.Title = "打开文件"; if (file.ShowDialog() == DialogResult.OK) { string filePath = file.FileName; }
这样获取的是名字和后缀
@小奉手:
大哥,你打个断点看看呀!