學習C#的文件系統的Directory類。比如,計算某目錄下的文件數量: class Be { public string Path { get; set; } public void GetPngFileList() { if (!Directory.Exists(Path)) { Console ...
學習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
演示: