学习C#的文件系统的Directory类。
比如,计算某目录下的文件数量:

计算目录下文件数

 

class Be
    {
        public string Path { get; set; }

        public void GetPngFileList()
        {
          
            if (!Directory.Exists(Path))
            {
                Console.WriteLine("指定的路径不存在。");
            }
            else
            {
                var files = Directory.GetFiles(Path, "*.*");
                Console.WriteLine("总共{0}个文档。",files.Length);
            }
        }
    }
Source Code

相关文章:

  • 2022-12-23
  • 2022-03-13
  • 2021-11-23
  • 2021-08-25
  • 2022-12-23
  • 2022-12-23
  • 2022-02-13
猜你喜欢
  • 2021-11-23
  • 2021-10-16
  • 2021-09-06
  • 2021-06-09
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
相关资源
相似解决方案