Filestream and BufferedStream

I am a little surprised we don’t get this question more often given the java story around buffered IO… but it came up today on an internal perf alias:


Is there any benefit in using a BufferedStream class over a FileStream if I can already specify a buffer size in the constructor of the FileStream class?

Answer (from Brian Grunkemeyer, dev for the System.IO namespace):

No, there is zero benefit from wrapping a BufferedStream around a FileStream. We copied BufferedStream’s buffering logic into FileStream about 4 years ago to encourage better default performance (Pit of Success). In fact, I don’t think there are any Streams in the .NET Framework that require it, but it might be needed by custom Stream implementations if they do not do buffering by default.