try
{
if (!Page.IsPostBack)
{
string strFileName;
string strFullPath;
string strFileDesc;
strFileName = Request.QueryString["Name"];
strFullPath = Request.PhysicalApplicationPath + "UploadFile//" + strFileName;
FileStream stream;
int nOffset;
int nCount;
byte[] arrByte;
int nEnd = 1;
arrByte = new Byte[100];
nCount = 100;
nOffset = 0;
System.IO.FileInfo fi=new System.IO.FileInfo("+ strFullPath +");
try
{
stream = File.Open(strFullPath,FileMode.Open);
Response.AddHeader("content-type","application/x-msdownload");
strFileDesc = string.Format("attachment;filename={0}",strFileName);
Response.AddHeader("Content-Disposition",strFileDesc);
Response.AddHeader("content-length",stream.Length.ToString());
while( (nEnd != 0) && (stream.Position < stream.Length))
{
nEnd = stream.Read(arrByte,nOffset,nCount);
Response.BinaryWrite(arrByte);
}
stream.Close();
Response.End();
}
catch
{
Response.Write ("<script>window.alert('文件不存在!');</script>");
Response.Write("<script>window.close();</script>");
}
}
}
catch
{}