1、打开选择文件对话框
1 string path = ""; 2 System.Windows.Forms.OpenFileDialog fd = new OpenFileDialog(); 3 fd.Title = "选择文件";//选择框名称 4 fd.Filter = "xls files (*.xls)|*.xls";//选择文件的类型为Xls表格 5 if (fd.ShowDialog() == DialogResult.OK)//当点击确定 6 { 7 path = fd.FileName.Trim();//文件路径 8 path = path.Replace("\\", "/"); 9 }