protected void LinkButton1_Click1( object sender , EventArgs e )
{
int row = ( (GridViewRow)( (LinkButton)sender ).NamingContainer ).RowIndex;
string wenname = subll.getgnamebyid( Convert.ToInt32( grshow.Rows[row].Cells[0].Text ) );
string filename = Server.MapPath( "~/" + subll.getway( Convert.ToInt32( grshow.Rows[row].Cells[0].Text ) ) );
DownLoad( wenname , filename );
}
private void DownLoad( string strName , string strPath )
{
string fileName = strName;//客户端保存的文件名
FileStream fs = new FileStream( strPath , FileMode.Open );
byte[] bytes = new byte[(int)fs.Length];
fs.Read( bytes , 0 , bytes.Length );
fs.Close( );
Response.ContentType = "application/octet-stream";
//通知浏览器下载文件而不是打开
Response.AddHeader( "Content-Disposition" , "attachment; filename=" + HttpUtility.UrlEncode( fileName , System.Text.Encoding.UTF8 ) );
Response.BinaryWrite( bytes );
Response.Flush( );
Response.End( );
}
点击linkbutton老是下载自己的这个aspx页面 不知道怎么回事。谷歌 火狐 没问题 求解释 ie8.。。什么的都有问题
- 9 回答
- 0 关注
- 428 浏览
添加回答
举报
0/150
提交
取消