Пример #1
0
 static void CountFile(StreamReader rdr, FileTypeStats stats)
 {
     stats.IncrementNumFiles();
     for (string line = rdr.ReadLine(); line != null; line = rdr.ReadLine())
     {
         stats.IncrementNumLines();
     }
 }
Пример #2
0
        static void WriteStats(TextWriter tw)
        {
            int num_files = 0;
            int num_lines = 0;

            foreach (string ext in statDictionary.Keys)
            {
                FileTypeStats stat = statDictionary[ext];
                stat.WriteStats(tw);
                num_files += stat.NumFiles;
                num_lines += stat.NumLines;
            }
            tw.WriteLine("Total");
            tw.WriteLine("Number of files: " + num_files.ToString());
            tw.WriteLine("Number of lines: " + num_lines.ToString());
        }
Пример #3
0
        static void CountFile(FileInfo fi)
        {
            string ext = fi.Extension.ToLower();

            if (includeDictionary.ContainsKey(ext) && !ignoreDictionary.ContainsKey(ext))
            {
                FileTypeStats stats = null;

                if (statDictionary.ContainsKey(ext))
                {
                    stats = statDictionary[ext];
                }
                else
                {
                    stats = new FileTypeStats(ext);
                    statDictionary.Add(ext, stats);
                }

                CountFile(fi, stats);
            }
        }
Пример #4
0
 static void CountFile(string path, FileTypeStats stats)
 {
     CountFile(File.OpenText(path), stats);
 }
Пример #5
0
 static void CountFile(FileInfo fi, FileTypeStats stats)
 {
     CountFile(fi.FullName, stats);
 }