TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
neo
NA
2
0
Download MS Word document through http
Nov 5 2006 10:05 AM
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 If
Please note i have to use http Web request only since the site throws up a login page which i am bypassing by
post
ing parameters.
Please help.
Thanks in advance!
Reply
Answers (
1
)
Dynamic DataGrid
Q: creating a simple keylogger