Howto open a file dialogbox (Save As) when using WriteFile

A

Anders

Hi,

This is the code I am using:

string filepath = "Themes/img/logo.rar";

string filename = System.IO.Path.GetFileName(filepath);
Response.Clear();
Response.ContentType = "application/zip";

Response.AddHeader("Content-Disposition", "attachment; filename=" +
filename);
Response.Flush();
Response.WriteFile(filepath);

Instead of the choice of saving the file its content is output in the
browser.

Thanks in advance,
Anders
 
S

Shiva

Hi,

Did you try Response.BinaryWrite instead of Response.WriteFile()?

Hi,

This is the code I am using:

string filepath = "Themes/img/logo.rar";

string filename = System.IO.Path.GetFileName(filepath);
Response.Clear();
Response.ContentType = "application/zip";

Response.AddHeader("Content-Disposition", "attachment; filename=" +
filename);
Response.Flush();
Response.WriteFile(filepath);

Instead of the choice of saving the file its content is output in the
browser.

Thanks in advance,
Anders
 
A

Anders

If I use BinaryWrite ill have to change all the code, specify the filepath
from the root and give ASPNET access to the path which I dont know how to do
in WinXP.

Best,
Anders
 
A

Anders

I added Reponse.Buffer = true just before the Response.Clear(); and now it
works!

Cheers,
A
 

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,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top