C# 浏览文件夹、获得文件夹及子目录下的所有文件

            FolderBrowserDialog dialog = new FolderBrowserDialog();
            dialog.Description = "请选择文件路径";
            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (string.IsNullOrEmpty(dialog.SelectedPath))
                {
                    System.Windows.MessageBox.Show(this, "文件夹路径不能为空", "提示");
                    return;
                }
                textBox4.Text = dialog.SelectedPath;
 
 
 
DirectoryInfo directory = new DirectoryInfo(textBox4.Text); FileInfo[] filelist = directory.GetFiles("*", SearchOption.AllDirectories);
 
 

猜你喜欢

转载自blog.csdn.net/glmushroom/article/details/73201267