日期:2014-05-18  浏览次数:20558 次

点击 LinkButton1 ,让客户下载文件,能行吗??
点击   LinkButton1   ,让客户下载文件,能行吗??

代码怎样写??

------解决方案--------------------
string name = Server.MapPath( "~/1.ascx ");
FileInfo aFile = new FileInfo(name);

Response.Clear();
Response.ClearHeaders();
Response.BufferOutput = false;
Response.ContentType = "application/octet-stream ";
Response.AppendHeader( "Content-disposition ", "attachment;filename=1.ascx ");
Response.AddHeader( "Content-Length ", aFile.Length.ToString());
Response.WriteFile(name);
Response.Flush();
Response.End();