I don't know of one in VS. Here is a quick an dirty console app that will
show you. Compile and put Linecount.exe in a dir in your path. Then just
run LineCount at the console in your project directory.
using System;
using System.Collecti ons.Generic;
using System.Text;
using System.IO;
namespace LineCount
{
class Program
{
static int totalCount = 0;
static void Main(string[] args)
{
string path = Environment.Cur rentDirectory;
DirectoryInfo di = new DirectoryInfo(p ath);
Console.WriteLi ne("Line count for all *.cs files in current
directory and all subdirectories. ");
ShowProjectLine Count(di);
Console.WriteLi ne("Total Project Count: {0}", totalCount);
}
public static void ShowProjectLine Count(Directory Info d)
{
// Curr dir.
FileInfo[] fis = d.GetFiles("*.c s");
foreach ( FileInfo fi in fis )
{
using ( StreamReader sr = fi.OpenText() )
{
string line;
int lineCount = 0;
while ( (line = sr.ReadLine()) != null )
{
lineCount++;
}
totalCount += lineCount;
Console.WriteLi ne("{0} {1}", lineCount, fi.FullName);
lineCount = 0;
}
}
// Subdirectories.
DirectoryInfo[] dis = d.GetDirectorie s();
foreach ( DirectoryInfo di in dis )
{
ShowProjectLine Count(di);
}
}
}
}
--
William Stacey [MVP]
"Bruce" <co*********@ne wsgroup.nospam> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Is there a mechanism within VS 2005 to determine the number of source code
lines in a C# project (either per file or across the entire project)?
Thanks, Bruce