We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,401 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

How to download files in listbox

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...

2
Contributors
3
Replies
4 Days
Discussion Span
2 Years Ago
Last Updated
5
Views
Question
Answered
linezero
Light Poster
25 posts since Nov 2010
Reputation Points: 11
Solved Threads: 0
Skill Endorsements: 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.")
codeorder
Postaholic
2,124 posts since Aug 2010
Reputation Points: 256
Solved Threads: 387
Skill Endorsements: 8

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

For Each itm As String In ListBox1.Items
linezero
Light Poster
25 posts since Nov 2010
Reputation Points: 11
Solved Threads: 0
Skill Endorsements: 0

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

codeorder
Postaholic
2,124 posts since Aug 2010
Reputation Points: 256
Solved Threads: 387
Skill Endorsements: 8
Question Answered as of 2 Years Ago by codeorder

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0630 seconds using 2.64MB