Beschreibung:
So kann man eine beliebige Datei mittels ASP.NET zum Download anbieten
/// <summary>
/// Starts the download.
/// </summary>
/// <param name="path">The path.</param>
private static void StartDownload(string path)
{
FileInfo downloadFile = new FileInfo(path);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", downloadFile.Name));
HttpContext.Current.Response.AddHeader("Content-Length", downloadFile.Length.ToString());
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.WriteFile(downloadFile.FullName);
HttpContext.Current.Response.End();
}
Schlagwörter: Download, Datei
Quelle: .NET-Snippets