Hello!

Can someone tell me how can i do following...

I would like to load a file from www and save it to folder. I am using Visual studio 2008 an VB in form aplication.
So how to load a file from example www.test.gg and saving it to c:/myfolder/


THX

Recommended Answers

All 3 Replies

>I would like to load a file from www and save it to folder.

Use methods of System.Net.HttpWebRequest class.

ufff..... i am not gettin' it.... can you be more specific?

>ufff..... i am not gettin' it.... can you be more specific?

Dim request As HttpWebRequest = CType(WebRequest.Create("url"), HttpWebRequest)

 request.MaximumAutomaticRedirections = 4
 
 request.MaximumResponseHeadersLength = 4

 request.Credentials = CredentialCache.DefaultCredentials
 
 Dim response As HttpWebResponse = CType(request.GetResponse(),  HttpWebResponse)

 ' Get the stream associated with the response.
 Dim receiveStream As Stream = response.GetResponseStream()

 Dim readStream As New StreamReader(receiveStream, Encoding.UTF8)
 
 Console.WriteLine(readStream.ReadToEnd())
 
 response.Close()
 
 readStream.Close()

...

Try to implement and if you run into problems and want to ask for help here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.