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);
posted @ 2016-10-17 17:53  扰扰  阅读(284)  评论(0编辑  收藏  举报