About Response.WriteFile();

A

ad

I want to download a zip (c:\test\mine.zip) in the server to client.
I modified the code form
http://support.microsoft.com/default.aspx?scid=KB;EN-US;q306654
and write it to a click event of a button:

string sFileName = @"c:\test\mine.zip";
//Response.ContentType = "Application/zip";
Response.WriteFile(sFileName);
Response.End();

I have two question:
1.
When use click the button, the default file name is not Mine.zip but
test.zip.
How can I set the file name to mine.zip?

2.
What ContentType should I set?
 
T

Teemu Keiski

1. Adding a content-disposition header should help

Response.AppendHeader("content-disposition",
"attachment;filename=mine.zip");

2. I think application/x-zip or application/zip should work
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top