Streaming a word doc to the browser...

S

Stu

Hi,

I have a Word document that is stored outside of the virtual server and I
need to send it to the browser. I have tried using the code below (which
seemed a little too simplistic!). The browser pops open a dialogue asking to
save a word doc but the doc is empty.


Dim f As File
f.Open("c:\test.doc", FileMode.Open)
'output file to the browser
Response.Clear()
Response.ContentType = "application/octet-stream; name=test.doc"
Response.AddHeader("content-transfer-encoding", "binary")
Response.AddHeader("content-disposition",
"attachment;filename=test.doc")
Response.ContentEncoding = System.Text.Encoding.GetEncoding(1251)
Response.Write(f)
f.Delete("c:\test.doc")

How to I route the document to the browser properly?

Thanks in advance,

Stuart
 
?

=?iso-8859-1?Q?Guillermo_Gonz=E1lez_A.?=

Hi Stu,

Use Response.BinaryWrite instead Reponse.Write

Guillermo G.

--------------------------------------------------------------------------------
Guillermo González Arroyave :: MCP ASP.Net C# :: DCE4

Hi,

I have a Word document that is stored outside of the virtual server and I
need to send it to the browser. I have tried using the code below (which
seemed a little too simplistic!). The browser pops open a dialogue asking to
save a word doc but the doc is empty.


Dim f As File
f.Open("c:\test.doc", FileMode.Open)
'output file to the browser
Response.Clear()
Response.ContentType = "application/octet-stream; name=test.doc"
Response.AddHeader("content-transfer-encoding", "binary")
Response.AddHeader("content-disposition",
"attachment;filename=test.doc")
Response.ContentEncoding = System.Text.Encoding.GetEncoding(1251)
Response.Write(f)
f.Delete("c:\test.doc")

How to I route the document to the browser properly?

Thanks in advance,

Stuart
 
S

Stu

That worked great thanks.


"Guillermo González A." <gugonzar(arroba)epm.net.co> wrote in message
Hi Stu,

Use Response.BinaryWrite instead Reponse.Write

Guillermo G.


Guillermo González Arroyave :: MCP ASP.Net C# :: DCE4

Hi,

I have a Word document that is stored outside of the virtual server and I
need to send it to the browser. I have tried using the code below (which
seemed a little too simplistic!). The browser pops open a dialogue asking to
save a word doc but the doc is empty.


Dim f As File
f.Open("c:\test.doc", FileMode.Open)
'output file to the browser
Response.Clear()
Response.ContentType = "application/octet-stream; name=test.doc"
Response.AddHeader("content-transfer-encoding", "binary")
Response.AddHeader("content-disposition",
"attachment;filename=test.doc")
Response.ContentEncoding = System.Text.Encoding.GetEncoding(1251)
Response.Write(f)
f.Delete("c:\test.doc")

How to I route the document to the browser properly?

Thanks in advance,

Stuart
 

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,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top