Hello everybody,
I need to download a file from the web using the HTTP-Protcoll. But
unfortunately I'm a total newbie. Found the following snippet some posts
ago:
Public Function DownloadFile(ByVal sUrl As String, _
ByRef sData As String) As Boolean
Dim myHttpWebRequest As HttpWebRequest = _
DirectCast(WebRequest.Create(sUrl), HttpWebRequest)
myHttpWebRequest.Method = "POST"
myhttpwebrequest.Proxy.Credentials
' Create a new string object to POST data to the Url.
Dim inputData As String = "cmd=" & HttpUtility.UrlEncode("login")
Dim postData As String = inputData
Dim encoding As New ASCIIEncoding
Dim byte1 As Byte() = encoding.GetBytes(postData)
' Set the content type of the data being posted.
myHttpWebRequest.ContentType = "application/x-www-form-urlencoded"
'Do I need to set cotnet type as below if transfer data file?
myHttpWebRequest.ContentType = "multipart/form-data encode"
' Set the content length of the string being posted.
myHttpWebRequest.ContentLength = postData.Length
Dim newStream As Stream = myHttpWebRequest.GetRequestStream()
newStream.Write(byte1, 0, byte1.Length)
newStream.Close()
' sData = ?
End Function
But how do I transform it to a GET-request (as I do not need to send any
data to the server)? Second, how do I get the data returned by
GetRequestStream into my String sData?
Need your help,
Stefan
--
___________________________________www.VBTricks.de .vu
the free resource for Visual Basic, Gambas and Pascal
components, tips & complete projects
www: http://www.VBTricks.de.vu
mail: vbtricks <at> gmx <dot> net
__________________________________________________ ___