Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Downloading unknown number of files from web server

Downloading unknown number of files from web server

Scheduled Pinned Locked Moved C#
visual-studiosysadminquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    steve_rm
    wrote on last edited by
    #1

    Hello, VS 2008 SP1 I am using the web client to download a file. Which works ok. However, now I have to download many, and the number of files to download will change everyday. And will not know the name of the files. I am not sure how I can get the web client to know which files have been downloaded or not? I was thinking of using a for loop to download each file. But I will never know how many there are to download? The web client could download the same file twice? Many thanks for any suggestions,

    private void btnStartDownload_Click(object sender, EventArgs e)
    {
    WebClient client = new WebClient();
    client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
    client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);

    // Starts the download
    client.DownloadFileAsync(new Uri("SomeURLToFile"), "SomePlaceOnLocalHardDrive");
    
    btnStartDownload.Text = "Download In Process";
    btnStartDownload.Enabled = false;
    

    }

    C 1 Reply Last reply
    0
    • S steve_rm

      Hello, VS 2008 SP1 I am using the web client to download a file. Which works ok. However, now I have to download many, and the number of files to download will change everyday. And will not know the name of the files. I am not sure how I can get the web client to know which files have been downloaded or not? I was thinking of using a for loop to download each file. But I will never know how many there are to download? The web client could download the same file twice? Many thanks for any suggestions,

      private void btnStartDownload_Click(object sender, EventArgs e)
      {
      WebClient client = new WebClient();
      client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
      client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);

      // Starts the download
      client.DownloadFileAsync(new Uri("SomeURLToFile"), "SomePlaceOnLocalHardDrive");
      
      btnStartDownload.Text = "Download In Process";
      btnStartDownload.Enabled = false;
      

      }

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Why would it download the same file twice ? Why would it miss a file ? Where does the list come from ? How do you hope to work out what you want ? You can work out what's been downloaded by checking if a file exists. That won't help you if the file needs to be downloaded again. You could keep a list in memory of files downloaded today and compare to your download list

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups