|
-
Mar 8th, 2010, 01:17 PM
#1
Thread Starter
Banned
download a file?
Hi Everyone,
Using vb 2005 how would I download a file from a password protected web directory?
Thanks in advance,
Dave
-
Mar 8th, 2010, 01:19 PM
#2
Re: download a file?
There are a few ways to do it. This is probably the most simple form.
Code:
Using WC As New Net.WebClient
WC.Credentials = New Net.NetworkCredential("username", "password")
WC.DownloadFile("http://www.somesite.com/somedir/somefile.zip", "C:\somefile.zip")
End Using
-
Mar 8th, 2010, 01:29 PM
#3
Thread Starter
Banned
Re: download a file?
Thanks for that
One more thing. Is there a way to get a list of all the files in the directory?
Thanks again,
Dave
-
Mar 8th, 2010, 01:30 PM
#4
Re: download a file?
If the webserver supports listing directory contents, otherwise you would need to use FTP classes/commands to get a directory listing.
-
Mar 8th, 2010, 01:57 PM
#5
Thread Starter
Banned
Re: download a file?
It does support it directory listing. I'm just not sure how to go about doing it.
-
Mar 8th, 2010, 02:01 PM
#6
Re: download a file?
For HTTP directory listing, you would need to manually parse the links out of the page, since there is so real standard for directory listing structures over HTTP.
If you can do it via FTP, it will be a more solid approach.
-
Mar 8th, 2010, 02:09 PM
#7
Thread Starter
Banned
Re: download a file?
Unfortunately FTP isn't an option.
-
Mar 8th, 2010, 02:18 PM
#8
Re: download a file?
Do you have control over the web server in question or no?
One option would be to have a server side scripted page (php, asp, asp.net, etc..) that could output a directory listing.
This way you know the exact format the given page will output, and makes it very easy to parse the data, since you know the format.
Otherwise, using the standard directory listing, you would need to use either standard string parsing, or regular expressions to extract the individual links out from the web servers directory listing.
-
Mar 8th, 2010, 03:02 PM
#9
Thread Starter
Banned
Re: download a file?
I do over the one I'm working with right now but wont with some others that I am adding. Reading and parsing the html is likely my best option.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|