C#打开文件对话框

OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = System.Environment.CurrentDirectory;//设定默认打开路径
if (ofd.ShowDialog() == DialogResult.OK)
{
    string filePathName = ofd.FileName;
    string fileName = Path.GetFileName(filePathName);  //文件名
    string extension = Path.GetExtension(fileName);   //扩展名
    string filePath = Path.GetDirectoryName(filePathName);
}

 

posted on 2016-01-13 08:23  万里驰骋  阅读(356)  评论(0编辑  收藏  举报

导航