ant2009
ant2009

Reputation: 22696

Downloading more than one file from a web server

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,

Private Sub btnStartDownload_Click(ByVal sender As Object, ByVal e As EventArgs)
 Dim client As New WebClient()
 AddHandler client.DownloadProgressChanged, AddressOf client_DownloadProgressChanged
 AddHandler client.DownloadFileCompleted, AddressOf client_DownloadFileCompleted

 ' Starts the download
 client.DownloadFileAsync(New Uri("UrlFilePath"), "DownloadPath")

 btnStartDownload.Text = "Download In Process"
 btnStartDownload.Enabled = False
End Sub

Upvotes: 0

Views: 1364

Answers (2)

MyItchyChin
MyItchyChin

Reputation: 14041

You could try using a multi-part content type and BinaryWrite but my understanding is that browser support for that content type is spotty at best.

How to download multiple files with one HTTP request?

Upvotes: 1

Shiraz Bhaiji
Shiraz Bhaiji

Reputation: 65491

We have previously built a system that required the the user download many files. The way we solved it was to zip the files on the server side then download it as a single file.

Upvotes: 1

Related Questions