C#选择文件保存路劲

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());
}
}
}

posted @ 2019-08-12 13:57  搬砖的L先生  阅读(1015)  评论(0编辑  收藏  举报