Downloading unknown number of files from web server
-
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;
}
-
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;
}
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.