C# 通过路径取文件方法

时间:2020-07-28 13:55:06   收藏:0   阅读:86
//使用
var filename = OpenfileDlg();

#region
通过路径取文件方法 /// <summary> /// 通过路径取文件方法 /// </summary> /// <param name="Defaultpath"></param> /// <returns></returns> private static string OpenfileDlg(string Defaultpath = null) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "请选择要打开的文件"; //多选 ofd.Multiselect = true; //初始目录 ofd.InitialDirectory = Defaultpath; //设定文件类型 // ofd.Filter = "*.bmp | *.jpg"; ofd.ShowDialog(); //获得在打开文件对话框中选择的文件的路径 string path = ofd.FileName; return path; } #endregion

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!