I was wondering if it is possible to increase buffer size on WebClient Async data upload, because currently it pushes ~320kB/s maximum.
My current code:
using (WebClient Client = new WebClient())
byte Buffer = File.ReadAllBytes(this.WorkItem.FileLocation);
Client.UploadProgressChanged += new UploadProgressChangedEventHandler(Client_UploadProgressChanged);
Client.UploadDataCompleted += new UploadDataCompletedEventHandler(Client_UploadDataCompleted);
Client.UploadDataAsync(new Uri("-snip-"), Buffer);
If you want more control over how the data is buffered you need to use the
HttpWebRequest class. With this class you can choose your read buffer reading from a
FileStream and then how much you are writing to the network stream. Doing 4MB reads and 32KB writes was optimal for maxing out my network throughput (although you will have to do your own benchmarks to see which buffers work best in your scenario).