1.11M Members

How to download files in listbox

 
0
 

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

the listbox has url
eg:

[url]http://www.hahaww.com/2.pdf[/url]
[url]http://www.hahaww.com/f1.pdf[/url]
[url]http://www.hahaww.com/24.pdf[/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...

 
0
 

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.
        Next
        MsgBox("Files Download Successful.")
 
0
 

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

For Each itm As String In ListBox1.Items
 
0
 

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

Question Answered as of 3 Years Ago by codeorder
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: