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