I needed to take some records in one file, do some stuff with the record, then put the results in another file. The 'do stuff' part was taking a bit longer than I thought it would so I wanted to see status. This sample illustrates taking 1000 records from a source file, uppercasing each line, putting it in another file, and letting us know every 100 lines.
using(TextWriter tw = new StreamWriter(@"uppercase.txt",false))
{
int i = 0;
var q = File.ReadAllLines(@"lowercase.txt").Take(1000);
foreach(var v in q)
{
tw.WriteLine("{0}", v.ToUpper());
//print status on every 100th record
if ((i % 100) == 0) Console.WriteLine("{0}/{1} processed", i.ToString(),q.Count().ToString());
i++;
}
Console.WriteLine("{0}/{1} processed", q.Count(),q.Count().ToString());
}