if (File.Exists(strDestinationPath))
{
byte[] file = File.ReadAllBytes(strDestinationPath);
// Create a memory stream from those bytes.
using (MemoryStream memory = new MemoryStream(file))
{
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(strDestinationPath));
Response.AppendHeader("content-length", file.Length.ToString());
Response.BinaryWrite(memory.ToArray());
Response.Flush();
Response.Close();
//Response.End();
}
}
else
{
ShowPopupAlert("File Does not Exists");
return;
}
Monday, December 16, 2013
How to download file with open/save dialog box in ASP.Net?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment