Tipx
Tipx

Reputation: 7515

Is pooling of StreamWriter.WriteLine Disk I/Os happening?

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?

Upvotes: 2

Views: 144

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1502496

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

Upvotes: 4

Related Questions