c#选择文件文件夹
C#选择文件
OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.InitialDirectory = "C://";
fileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
fileDialog.FilterIndex = 1;
fileDialog.RestoreDirectory = true;
if (fileDialog.ShowDialog() == DialogResult.OK)
{
this.textBox1.Text = fileDialog.FileName;
}
C#选择文件夹
string path = ""; FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); folderBrowserDialog.ShowNewFolderButton = false; if (folderBrowserDialog.ShowDialog() == DialogResult.OK) { path = folderBrowserDialog.SelectedPath; } else { } this.textBox1.Text = path;
得到文件夹下文件目录
string[] dataFiles = Directory.GetFiles(path);