Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically save from a URL

Status
Not open for further replies.

paulcy82

Programmer
Jan 25, 2005
28
0
0
US
I have a form that when I click a button on the form, I use shell to open IE and go to a link that prompts me to save a zip file. I want this to be automatic. I want to click the button and the file will be automatically saved to a directory that I specify in my code.
 
Hi,
If I understood your problem correctly, you could try using WebRequest from your app rather than opening IE. Something like this bit of code might help (I haven't tested the streamwriter bit so that might need tweaking):

Imports System.Net
Imports System.IO

Dim URL as String = "Dim webReq As WebRequest = WebRequest.Create(URL)
Dim webRes As WebResponse = webReq.GetResponse

Dim StreamReader As New StreamReader(webRes.GetResponseStream)

Dim StreamWriter As New StreamWriter("C:\path\filename.zip")
StreamWriter.Write(StreamReader.ReadToEnd)
StreamWriter.Close()
StreamReader.Close()
webRes.Close()

Let me know how you get on!
Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top