首页 > Windows开发 > 详细

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

时间:2020-06-17 13:30:43      阅读:67      评论:0      收藏:0      [点我收藏+]
 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

原文:https://www.cnblogs.com/Fred1987/p/13151781.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!