2

I'm trying to find if the .net framework pools StreamWriter.WriteLine()s before writing them, or if it does it as they come and I can't find an answer on MSDN. For example, if I have this simplistic code :

StreamWriter sw = [Whatever];
for (int i = 0; i < 100000; i++)
{
    sw.WriteLine(string.Format("Whatever : {0}", i);
}

Would this write 100000 times to the disk, or will the framework pool some of them together?

Tipx
  • 7,367
  • 4
  • 37
  • 59

1 Answers1

4

It depends on the value of the AutoFlush property, as well as the buffer size, which can be specified on construction.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • I narrowed my search to the Write/WriteLine methods too fast and I missed that. I'm ashamed! Thanks sir! – Tipx May 28 '12 at 15:24