DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Write File To Response Stream

01.29.2007
| 9120 views |
  • submit to reddit
        // Wrtites temporary file to response stream and then delete
Response.Clear();
Response.ContentType = "image/tiff";
Response.AddHeader("Content-Disposition", "attachment; filename=imageFile.tiff");
Response.WriteFile(tempPath);
Response.Flush();
Response.Close();
if(File.Exists(tempPath)){
    File.Delete(tempPath);
}