码迷,mamicode.com
首页 > 其他好文 > 详细

遍历文件夹.ZC测试

时间:2019-10-12 15:54:02      阅读:87      评论:0      收藏:0      [点我收藏+]

标签:提示   rgs   eve   文件夹路径   erb   inf   目录   getdir   遍历   

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、

 

遍历文件夹.ZC测试

标签:提示   rgs   eve   文件夹路径   erb   inf   目录   getdir   遍历   

原文地址:https://www.cnblogs.com/csskill/p/11661945.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!