Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

webclient downloading many files from web server

Status
Not open for further replies.

robUK2

Programmer
Mar 10, 2008
57
0
0
TH
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.

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,

Code:
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;
}
 
Is there a listing page that links to the files. If so you can use HttpWebRequest and HttpWebResponse to read the page extract all of the file links using regular expressions then run your code to get all of the files calling the hrefs of the links that were returned.

If this sounds like something that will work for you I can work on some code later on today to demo that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top