what is the size of the internal buffer of fileStream

T

Tony Johansson

Hi!

If I use a filestream connected to a data storage like this program example
shown here. The data will be written to the data storage when the internal
buffer is full. So I just wonder what size is it on the internal buffer ?
I mean the actual write to the data storage will be done in chunks of some
size to increase the performance.

string overview = "Most commercial applications, such as...";
FileInfo fileStore = new FileInfo("Overview.txt");
FileStream conduit = fileStore.Create();
byte[] encodedOverview = new UTF8Encoding(true).GetBytes(overview);
conduit.Write(encodedOverview, 0, encodedOverview.Length);
conduit.Close();

//Tony
 
A

Arne Vajhøj

If I use a filestream connected to a data storage like this program example
shown here. The data will be written to the data storage when the internal
buffer is full. So I just wonder what size is it on the internal buffer ?
I mean the actual write to the data storage will be done in chunks of some
size to increase the performance.

string overview = "Most commercial applications, such as...";
FileInfo fileStore = new FileInfo("Overview.txt");
FileStream conduit = fileStore.Create();
byte[] encodedOverview = new UTF8Encoding(true).GetBytes(overview);
conduit.Write(encodedOverview, 0, encodedOverview.Length);
conduit.Close();

If you need a specific buffer size then use a FileStream
construct where you can specify it.

Otherwise don't rely on it having a specific value.

Reflector reveals that default in MS .NET 2.0 just happens to
be 0x1000.

Also check the BufferedStream class.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top