【发布时间】:2011-12-09 05:45:14
【问题描述】:
我试图在 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 +"";
}
【问题讨论】:
标签: c# .net filenames openfiledialog