Click here to Skip to main content
13,351,457 members (46,199 online)
Click here to Skip to main content
Add your own
alternative version


7 bookmarked
Posted 27 Jan 2013

C# Web File Download with BITSadmin

, 27 Mar 2013
Rate this:
Please Sign up or sign in to vote.
When WebClient, HttpRequest, and all else fail, BITSadmin solves your download woes


I was making an app that required downloading files from a website.  In the past, I’ve used WebClient (excellent for most scenarios), HttpWebRequest (clunky), and even the Forms WebBrowser (very messy) to accomplish the deed.  For this particular app however, all of these methods failed due to the dreaded “server protocol violation” error.  Argh!!!  With some digging, I found a console executable that was right for the job, so I made a simple method to use it in my app.  Success!  

Using the code 

A brief description of how to use the article or code. The
class names, the methods and properties, any tricks or tips.

Blocks of code should be set as style "Formatted"
like this:

string local = @"C:\Users\metastruct\Desktop\my_image.jpg";

string remote = @"”;

download(remote, local);

That easy to use!

The Code

private void download(string remote_file_url, string local_file)
        /* Create the Process */
        System.Diagnostics.Process bitsadmin_process = new System.Diagnostics.Process();
        /* Assign the BITSadmin Executable and Arguements to the Process */
        bitsadmin_process.StartInfo = new System.Diagnostics.ProcessStartInfo("bitsadmin", "/transfer mydownloadjob  /download /priority normal " + remote_file_url + " " + local_file);
        /* Start the Process */
        /* Wait While the File Downloads */
        /* Dispose the Process */
        bitsadmin_process = null;
    catch { }


Such a simple solution to such an annoying problem.  Caution: downloading to a share drive gave me issues, so I downloaded locally and used File.Copy() to transfer.  Next step would be some improved error handling/redirection from the Process, but this works for now. Check out more at 


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralToo bad ;) Pin
Member 979571828-Mar-13 9:48
memberMember 979571828-Mar-13 9:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.180111.1 | Last Updated 27 Mar 2013
Article Copyright 2013 by metastruct
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid