选择文件
1 //选择文件 2 OpenFileDialog dialog = new OpenFileDialog(); 3 dialog.Multiselect = true;//该值确定是否可以选择多个文件 4 dialog.Title = "请选择文件夹"; 5 dialog.Filter = "所有文件(*.*)|*.*"; 6 if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) 7 { 8 string file = dialog.FileName; 9 }
选择文件夹
1 FolderBrowserDialog dialog = new FolderBrowserDialog(); 2 dialog.Description = "请选择文件路径"; 3 dialog.SelectedPath = path; 4 //dialog.RootFolder = Environment.SpecialFolder.Programs; 5 if (dialog.ShowDialog() == DialogResult.OK) 6 { 7 string foldPath = dialog.SelectedPath; 8 }
手拿菜刀砍电线,一路火花带闪电。
高楼大厦平地起,靠谁不如靠自己