protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Download") { string Filepath = e.CommandArgument.ToString(); string path = MapPath(Filepath); byte[] bts = System.IO.File.ReadAllBytes(path); Response.Clear(); Response.ClearHeaders(); Response.AddHeader("Content-type", "application/octect-stream"); Response.AddHeader("Content-Length", bts.Length.ToString()); Response.AddHeader("Content-Disposition", "attachment; Filepath=" + Filepath); Response.BinaryWrite(bts); Response.Flush(); Response.End(); } }
MapPath(Filepath)
Filepath
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)