Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save KresimirKoncicNeuralab/7960893 to your computer and use it in GitHub Desktop.
Save KresimirKoncicNeuralab/7960893 to your computer and use it in GitHub Desktop.
File force download [c#]
// full path to your file
string yourFilePath = HttpContext.Current.Request.PhysicalApplicationPath + "imageFolder\\yourFile.jpg";
// save downloaded file as (name)
string saveFileAs = "yourFile.jpg";
Response.Clear();
Response.AddHeader("content-disposition", "attachment; filename=" + saveFileAs);
Response.WriteFile(yourFilePath);
Response.ContentType = "";
Response.End();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment