C# read and compute the code lines number of cs files based on given directory

 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);
        }

 

C# read and compute the code lines number of cs files based on given directory

上一篇:在WIN上使用TORCS模拟器做深度强化学习(2)


下一篇:SQL 优化原则