我没有在我的VS2008中的功能,所以几个月前,我实现了一个快速和脏的Windows应用程序,计算我的C#文件中的CRLF数量。当然,这可以用VS生成的文件中的空行和行数进行计数,但是稍微调整一下,我相信你可以使它产生很好的计数。这是Windows窗体中的操作代码;该dlgFolder控制是FolderBrowserDialog控件:
if (dlgFolder.ShowDialog() == DialogResult.OK)
{
int totalLines = 0;
string[] fileList = Directory.GetFiles(dlgFolder.SelectedPath, "*.cs", SearchOption.AllDirectories);
for (int x = 0; x < fileList.Length; x++)
{
string[] sourceCodeLines = File.ReadAllLines(fileList[x]);
totalLines += sourceCodeLines.Length;
}
MessageBox.Show(String.Format("There are {0} lines of C# code in the folder{1}",
totalLines.ToString(), dlgFolder.SelectedPath));
}
在这里看到:http://stackoverflow.com/questions/1244729/how-do-you-count-the -v-line-of-a-visual-studio-solution拥有一个更好更灵活的powershell命令,然后Javier在unix中提供给他。 – 2011-11-10 18:13:38