Posts
265
Comments
80
Trackbacks
4
Eine Datei mit ASP.NET zum Download anbieten

In ASP.NET gibt es eine einfache Möglichkeit eine Datei zum Download anzubieten:

string dateiname = HttpContext.Current.Server.MapPath("Verzeichnis/Dateiame");

System.IO.FileInfo downloadDatei = new System.IO.FileInfo(dateiname);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + downloadDatei.Name);
HttpContext.Current.Response.AddHeader("Content-Length", downloadDatei.Length.ToString());
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.WriteFile(downloadDatei.FullName);
HttpContext.Current.Response.End();

posted on Thursday, December 01, 2005 8:07 AM Print
Comments
No comments posted yet.

Post Comment

Title *
Name *
Email
Url
Comment *  
Please add 1 and 1 and type the answer here: