C# 通过路径取文件方法

//使用
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

猜你喜欢

转载自www.cnblogs.com/qq2806933146xiaobai/p/13390096.html
今日推荐