winform 点击按钮选择文件保存的路径,效果如下图:
具体代码如下:
private void button8_Click(object sender, EventArgs e) { FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.Description = "请选择文件路径"; if (dialog.ShowDialog() == DialogResult.OK) { string foldPath = dialog.SelectedPath; DirectoryInfo theFolder = new DirectoryInfo(foldPath); //theFolder 包含文件路径 FileInfo[] dirInfo = theFolder.GetFiles(); //遍历文件夹 foreach (FileInfo file in dirInfo) { MessageBox.Show(file.ToString()); } } }
原文地址:https://www.cnblogs.com/youmingkuang/p/9723673.html
时间: 2024-10-29 04:10:38