Simple Line Count for your VS Projects and Solutions.

Compile this code as a Console app, put the Exe in your path.  Then when inside one of your Project directories, just type linecount to see all the lines in all *.cs files in your project dir and all subdirectories.  This does not figure out if  each .cs is actually included in your project or not, but I guess that could be added.  There may be some macro you could do inside VS, if so, please let me know.

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace LineCount
{
    class Program
    {
        static int totalCount = 0;

        static void Main(string[] args)
        {
            string path = Environment.CurrentDirectory;
            DirectoryInfo di = new DirectoryInfo(path);
            Console.WriteLine("Line count for all *.cs files in current directory and all subdirectories.");
            ShowProjectLineCount(di);
            Console.WriteLine("Total Project Count: {0}", totalCount);
        }

        public static void ShowProjectLineCount(DirectoryInfo d)
        {
            // Curr dir.
            FileInfo[] fis = d.GetFiles("*.cs");
            foreach ( FileInfo fi in fis )
            {
                using ( StreamReader sr = fi.OpenText() )
                {
                    string line;
                    int lineCount = 0;
                    while ( (line = sr.ReadLine()) != null )
                    {
                        lineCount++;
                    }
                    totalCount += lineCount;
                    Console.WriteLine("{0} {1}", lineCount, fi.FullName);
                    lineCount = 0;
                }
            }
            // Subdirectories.
            DirectoryInfo[] dis = d.GetDirectories();
            foreach ( DirectoryInfo di in dis )
            {
                ShowProjectLineCount(di);
            }
        }
    }
}

 

— William

Advertisements
This entry was posted in C#. Bookmark the permalink.

One Response to Simple Line Count for your VS Projects and Solutions.

  1. Unknown says:

    http://www.batteryfast.com/hp/dv2200.htm Hp dv2200 Battery http://www.batteryfast.com/hp/dv4000.htm Hp dv4000 Battery http://www.batteryfast.com/hp/dv6000.htm Hp dv6000 Battery http://www.batteryfast.com/ibm/thinkpad-t40.htm Ibm thinkpad t40 Battery http://www.batteryfast.com/toshiba/satellite-a105.htm Toshiba satellite a105 Battery http://www.batteryfast.com/toshiba/satellite-m45.htm Toshiba satellite m45 Battery http://www.batteryfast.com/toshiba/pa3285u-3bas.htm Toshiba pa3285u-3bas Battery http://www.batteryfast.com/toshiba/pa3395u-1brs.htm Toshiba pa3395u-1brs Battery http://www.batteryfast.com/toshiba/pa3399u-1bas.htm Toshiba pa3399u-1bas Battery http://www.batteryfast.com/toshiba/pa3399u-1brs.htm Toshiba pa3399u-1brs Battery http://www.batteryfast.com/toshiba/pa3399u-2bas.htm Toshiba pa3399u-2bas Battery http://www.batteryfast.com/toshiba/pa3399u-2brs.htm Toshiba pa3399u-2brs Battery http://www.batteryfast.com laptop battery http://www.batteryfast.com laptop batteries http://www.batteryfast.com/toshiba/pa3465u-1brs.htm Toshiba pa3465u-1brs Battery http://www.batteryfast.com/toshiba/pa3534u-1brs.htm Toshiba pa3534u-1brs Battery http://www.batteryfast.com/toshiba/pa3594u-1brs.htm Toshiba pa3594u-1brs Battery http://www.batteryfast.com/uniwill/255-3s4400-g1l1.htm Uniwill 255-3s4400-g1l1 Battery http://www.batteryfast.com/uniwill/258-4s4400-s1p1.htm Uniwill 258-4s4400-s1p1 Battery http://www.batteryfast.com/hp/pavilion-dv9000.htm HP pavilion dv9000 Battery http://www.batteryfast.com/hp/pavilion-dv9700.htm HP pavilion dv9700 Battery http://www.batteryfast.com/hp/pavilion-dv9500.htm HP pavilion dv9500 Battery http://www.batteryfast.com/hp/pavilion-dv9600.htm HP pavilion dv9600 Battery http://www.batteryfast.com/dell/inspiron-b130.htm Dell inspiron b130 Battery http://www.batteryfast.com/dell/inspiron-mini-9.htm Dell inspiron mini 9 Battery http://www.batteryfast.com/hp/nc8230.htm Hp nc8230 Battery http://www.batteryfast.com/hp/nc8430.htm Hp nc8430 Battery http://www.batteryfast.com/hp/nw8000.htm Hp nw8000 Battery http://www.batteryfast.com/hp/nw8200.htm Hp nw8200 Battery http://www.batteryfast.com/hp/nc6000.htm Hp nc6200 Battery http://www.batteryfast.com/hp/nc6100.htm Hp nc6100 Battery http://www.batteryfast.com/hp/nc6120.htm Hp nc6120 Battery http://www.batteryfast.com/hp/nc6400.htm Hp nc6400 Battery http://www.batteryfast.com/hp/pavilion-dv2000.htm Hp pavilion dv2000 Battery http://www.batteryfast.com/hp/pavilion-dv6000.htm Hp pavilion dv6000 Battery http://www.batteryfast.com/hp/pavilion-dv8000.htm Hp pavilion dv8000 Battery http://www.batteryfast.com/hp/pavilion-dv9000.htm Hp pavilion dv9000 Battery http://www.batteryfast.com/hp/pavilion-dv9500.htm Hp pavilion dv9500 Battery http://www.batteryfast.com/hp/pavilion-dv9600.htm Hp pavilion dv9600 Battery http://www.batteryfast.com/hp/pavilion-dv9700.htm Hp pavilion dv9700 Battery http://www.batteryfast.com/laptop-ac-adapter/acer/aspire-5520.htm Acer aspire 5520 Adapter http://www.batteryfast.com/laptop-ac-adapter/acer/aspire-5920.htm Acer aspire 5920 Adapter http://www.batteryfast.com/dell/kd476.htm Dell kd476 Battery http://www.batteryfast.com/dell/kr-onx511.htm Dell kr-onx511 Battery http://www.batteryfast.com/dell/latitude-d620.htm Dell latitude d620 Battery http://www.batteryfast.com/dell/latitude-d630.htm Dell latitude d630 Battery

Comments are closed.