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