遍历文件夹.ZC测试

1、

        string FstrSelectPath = @"D:\ZC_RuanJian\movie\test01\小猪佩奇(持续更新)\小猪佩奇中文版 1080P\小猪佩奇中文版第7季 1080P";

        private void Click_SelectFolder(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
            dialog.Description = "请选择文件夹";
            dialog.SelectedPath = FstrSelectPath;
            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (string.IsNullOrEmpty(dialog.SelectedPath))
                {
                    MessageBox.Show(this, "选择的文件夹路径为空", "提示");
                    return;
                }

                FstrSelectPath = dialog.SelectedPath;
                tbSelectedFolder.Text = FstrSelectPath;
            }
        }

        List<string> BianLiFile01(string _strPath)
        {
            //C#遍历指定文件夹中的所有文件 
            DirectoryInfo folder = new DirectoryInfo(_strPath);
            if (!folder.Exists)
            {
                MessageBox.Show("文件夹不存在", "提示");
                return null;
            }

            List<string> list = new List<string>();

            //遍历文件
            foreach (FileInfo file in folder.GetFiles())// folder.GetDirectories() 目录
                list.Add(file.Name);
            return list;
        }

 

2、

3、

4、

5、

 

posted @ 2019-10-12 15:44  csskill  阅读(134)  评论(0编辑  收藏  举报