As part of my current project I'm working on using C#. My assigment involves to download files (some of them quite large) from an HTTP server, I know this is not rocket rocket science specially in .net world.
So while I can succesfully download the files, my issue is that no method I've tried including the built in WebClient class can match the speed when I try to download the same file using IE or any other web browser.
Of course the question is if any of you guys how the browsers download the files and how can I implement such a method in C#?
Thanx in advance,
PS: Yes I've googled/binged this to no success so far.
using System.Net; ...
WebClient wc = new WebClient(); wc.DownloadFile(httpHostName, localFileName);
Under the hood this is using the same mechanism to download the files as Internet Explorer (WinInet/WinHttp).
And in case WebClient is not enough (rarely the case), you can always resort to HttpWebRequest.
also you may need to check on buffer sizes ..... i bet the browser does some tuning that your app does not do.
for example if the http stream is coming back with 4 meg chunks then the client buffer size should be some multiple of that value so that it does not have to alloc more storage while downloading.
stuff like that can make a huge difference in perf.
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.