我沒有在我的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