encoding for .exe file

Hi, Gurus,

I am developing an application which can automatically download updated version (as .exe file). I am wondering what kind of encoding or code should i use in .net, my following code seems to work only for .txt file. Thanks.

Public Function WebDownload(ByVal remoteFileFullUrl As String, ByVal localFilePath As String, ByVal proxyserver As String, Optional ByVal proxyport As String = "80") As Boolean
Dim proxyObject As WebProxy
Dim webreq As HttpWebRequest
Dim webresp As HttpWebResponse
Dim strm As StreamReader

' Create a HttpWebRequest object on the url
webreq = HttpWebRequest.Create(remoteFileFullUrl)
If proxyserver <> "" Then
proxyObject = New WebProxy(proxyserver, True)
webreq.Proxy = proxyObject
End If

' Get a HttpWebResponse object from the url
webresp = webreq.GetResponse()

' Create a StreamReader object and pass the stream as a parameter
strm = New StreamReader(webresp.GetResponseStream(), Encoding.ASCII)

Dim myFile As System.IO.FileStream
myFile = IO.File.Create(localFilePath)
Dim ret As String

' Read each line from the stream (from the server)
While strm.Peek() > -1
ret = strm.ReadLine()
myFile.Write(Encoding.ASCII.GetBytes(ret), 0, ret.Length())
End While


' Close the stream to the server and free the resources.

End Function
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!