I have tried many ways to download the files in a listbox. non-seems to work.

the listbox has url


I want to download the files until ListBox.Items.Count = 0 which each file with number ording...
for eg:
2.pdf will be 1.pdf
f1.pdf will be 2.pdf
24.pdf will be 3.pdf

and so on until ListBox.Items.Count = 0
all files will be downloaded until ListBox.Items.Count = 0

to download i have used

My.Computer.Network.DownloadFile(ListBox1.SelectedItem, "c:\temp\1.pdf")

i also couldnt find a way to increase the numbering...

Recommended Answers

All 3 Replies

See if this helps to download all web files from a ListBox.

Dim myFolder As String = "C:\" '// folder to save files to.
        Dim sFileExtension As String = Nothing '// string to get the file extension from web file.
        Dim iFileNameNumber As Integer = 0 '// used to save file names as #'s.
        For Each itm As String In ListBox1.Items '// loop thru all items.
            sFileExtension = itm.Substring(itm.LastIndexOf("."c)) '// get file .Extension from web file path of ListBox item.
            iFileNameNumber += 1 '// increment for FileName.
            My.Computer.Network.DownloadFile(itm, myFolder & iFileNameNumber & sFileExtension) '// Download file.
        MsgBox("Files Download Successful.")

I get an error saying "Conversion from type 'Match' to type 'String' is not valid."

For Each itm As String In ListBox1.Items

Can you post the entire For/Next loop code and specify which line is giving you the finger, I mean "error".:D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.