2

I am writing a stream to a file by

stream.CopyToAsync(fileStream, [bufferSize])

I want to know how much buffer size is better to use for a faster operation?

files are from 100KB to 1 or 2 megabyte.

user2799350
  • 389
  • 1
  • 4
  • 14
  • 1
    Why are you considering the overloading taking a bufferSize if don't know a better value than the default of 4096? What about calling Strea.CopyToAsync(fileStream) and let .NET handle buffer sizes for you? Are you having performance issues with such solution? – sisve Sep 25 '13 at 05:59
  • I didn't know about the default :) thanks – user2799350 Sep 25 '13 at 06:05
  • 2
    Please be aware that the default depends on the .NET version you are using, for .NET 4.5 the default buffer size for Stream.CopyToAsync() is 81920 - see http://msdn.microsoft.com/en-us/library/hh158751(v=vs.110).aspx and http://stackoverflow.com/a/1933764/700926 – Lasse Christiansen Jul 15 '14 at 22:45

0 Answers0