System.Net.WebClient.DownloadFile does not work all the time.

Discussion in 'Software' started by Girish_Kamalapur, Jun 23, 2013.

  1. Girish_Kamalapur


    Jun 23, 2013
    Likes Received:

    I need to download the images from websites.
    I am using following code, in my ASP.Net application with framework 4.0.

    System.Net.WebClient wc = new System.Net.WebClient();
    wc.DownloadFile(finalPath, String.Format(destDir + "\\" + file));
    finalPath is holding the url of .gif file, destDir is my local folder and file is the name which I want to save the file as.
    This works some times, but most of the time all the down loaded image files (gif,jpg,png) have a same size and all images will be corrupt. It will not be possible to see the images in preview.
    What I am missing here?
    Is there any other was to download the image using .Net code?
    Is there any setting need to be changed?

    Thank you for the help in advance.
    Girish_Kamalapur, Jun 23, 2013
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.