бредущий по жизни (svoysredychuzih) wrote in aspdotnet,
бредущий по жизни
svoysredychuzih
aspdotnet

Renaming file on-fly

Hello,
I do have a file on web server, let's say 123.zip
When I am redirecting user to it, browser opens Save dialog and puts that name by default: 123.zip. Is there any way to change that name to, let's say 456.zip?
File 123.zip stays on server as 123.zip, but user sees it as 456.zip.

One of the known ways is:

Byte[] data = System.IO.File.ReadAllBytes(sFullName); // 123.zip
Response.AddHeader("Content-Disposition", "attachment; filename=456.zip");
Response.OutputStream.Write(data, 0, data.Length);
Response.End();

But in this case I have to read the whole file first and then stream it out. Works fine with small files, but 123.zip could be huge. Then browser freezes and ends by timeout.

Thank you.
  • Post a new comment

    Error

    default userpic
  • 0 comments