System.Net.WebClient Error

Joined
Aug 19, 2006
Messages
1
Reaction score
0
I'm trying to open a server side MS-Word document and present it client side. I just want the word document to appear inside the browser or open up for viewing. When I run the code I'm prompted to "Open" or "Save" the file. If I "Save" the file it is the file that I requested but if I "Open" I get the following error: "This file could not be found. Try one or more of the following: * Check the spelling of the name of the document. * Try a different file name."

Code:
Dim _webClient As New System.Net.WebClient
Dim sURI aAs String = "file://C:\test.doc"
Dim theBuffer As Byte() = _webClient.DownloadData(sURI)
With Page.Response
.ClearContent()
.ContentType = "application/msword"
.AddHeader("content-disposition", "attachement;filename=test.doc")
.OutputStream.Write(theBuffer, 0, theBuffer.Length)
.End
End With
_webClient.Dispose()

Please tell if I'm going down the wrong direction by using WebClient.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top