Link to home
Start Free TrialLog in
Avatar of donniedarko801
donniedarko801

asked on

Http file download & Keeping original file name. How?

Hello experts,

I have this small piece of code and it works great except I have to hard code the local file name. Is there a way to save downloaded file with original file name?

       Dim sSourceUrl As String    ' File to download with URL
       Dim sLocalFile As String    ' File to crate on the local system
       
       Dim client As New WebClient

       sSourceUrl = "http://www.download.com/file.txt"
       sLocalFile = "c:\Temp\file.txt"

       client.DownloadFile(sSourceUrl, sLocalFile)

Thanks for anything.

ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of donniedarko801
donniedarko801

ASKER

Thanks a lot!

Just out of curiosity, how would you download an http folder and all files within from a website?

I'll be happy to start another question if need be.