C# read and compute the code lines number of cs files based on given directory
时间:2020-06-17 12:48:11
收藏:0
阅读:67
static void ComputeCodeLines() { string dir = @"D:\Work"; int totalLines = 0; string[] allFiles = Directory.GetFiles(dir, "*.cs", SearchOption.AllDirectories); if(allFiles!=null && allFiles.Any()) { foreach(var file in allFiles) { string[] contents = File.ReadAllLines(file); totalLines += contents.Length; } } Console.WriteLine(totalLines); }
评论(0)