static void CountFile(StreamReader rdr, FileTypeStats stats) { stats.IncrementNumFiles(); for (string line = rdr.ReadLine(); line != null; line = rdr.ReadLine()) { stats.IncrementNumLines(); } }
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()); }
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); } }
static void CountFile(string path, FileTypeStats stats) { CountFile(File.OpenText(path), stats); }
static void CountFile(FileInfo fi, FileTypeStats stats) { CountFile(fi.FullName, stats); }