Download file returning 0 K Byte with http: but with Physical path

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

private void Button1_Click(object sender, System.EventArgs e)
{

Context.Response.Clear();
Context.Response.ContentType = "application/octet-stream";
Context.Response.AppendHeader("accept-ranges", "bytes");
Context.Response.AddHeader("Content-Disposition", "attachment; filename=" +
"test.zip");
Context.Response.BufferOutput = false;

Context.Response.Flush();
Context.Response.TransmitFile("c:\\test.zip");

when I use the Physical path it save the file succeesfully in the
destination folder
but when I replace the above Physical path line with the below virtual path
line it dowload the file successfully but with 0 KByte.

Context.Response.TransmitFile("http://test.com/Client/test.zip");



//Context.Response.
}
}
}
 
Use MapPath to get the physical path of the location you wish to save the
file at. You can then save to that path and use a relative path to display
the file.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
Back
Top