Bir*_*man 44 .net c# filenames openfiledialog
我试图只包括我在label1.Text属性中的OpenFileDialog中选择的文件的文件名,但我还没有找到解决方案.我知道我可以使用ofd实例上的字符串类中的方法来过滤掉文件的整个路径,但我想知道是否存在更智能/更快捷的方法?
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "Find song";
ofd.Filter = "MP3 files|*.mp3";
ofd.InitialDirectory = @"C:\";
if (ofd.ShowDialog() == DialogResult.OK)
{
label1.Text = "" + ofd.FileName +"";
}
Run Code Online (Sandbox Code Playgroud)
Waq*_*aja 89
OpenFileDialog.SafeFileName获取在对话框中选择的文件的文件名和扩展名.文件名不包含路径.
Dav*_*ras 31
var onlyFileName = System.IO.Path.GetFileName(ofd.FileName);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
98304 次 |
| 最近记录: |