c#中怎么获取当前文件的绝对路径

2024-12-04 15:45:22
推荐回答(1个)
回答1:

var 当前可执行文件的绝对路径 = System.Environment.CurrentDirectory;
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "Audio Files (*.*)|*.*";
dialog.ShowDialog();
var 选择文件的绝对路径 = dialog.FileName.Remove(dialog.FileName.LastIndexOf ("\\"));