Hi,
I am connecting to a web site using HttpWebRequest, and opening a file url, which is actually a MS word doc.I need to download the same through backend, but the file, on downloading, is getting corrupted.I think the problem is with the
encoding.Here is how i am doing it:
Dim wReq as HttpWebRequest
Dim wResp as HttpWebResponse
Dim str as String
Dim sr as StreamReader
Dim sw as StreamWriter
wReq = CType(WebRequest.Create(New Uri(strURL)),HttpWebRequest)
wReq.Method = "POST"
wReq.KeepAlive = True
wReq.
Credentials = New NetworkCredential(user, passwd, domain)
wReq.ContentType = "application/msword"
wResp = wReq.GetResponse
sr = New
StreamReader(wResp.GetResponseStream, System.Text.Encoding.ASCII)
str = sr.ReadToEnd.Trim
sr.Close()
wResp.Close()
wReq = Nothing
If
Not str Is Nothing And str.Length > 0 Then
sw =
New StreamWriter(dFolder & filename & "." & "doc", False)
sw.WriteLine(txt)
sw.Close()
sw = Nothing
End IfPlease note i have to use http Web request only since the site throws up a login page which i am bypassing by
posting parameters.
Please help.
Thanks in advance!