问题描述
privatevoidDownFile(stringpath){stringserverpath=Server.MapPath(path);FileInfofi=newFileInfo(serverpath);if(fi.Exists){constintsize=2048;byte[]buffer=newbyte[size];Response.Clear();FileStreamfs=File.OpenRead(serverpath);intdata=fs.Length;Response.ContentType="application/octet-stream";Response.AddHeader("ContentType-Disposition","attachment;filename="+HttpUtility.UrlEncod(Path.GetFileName(serverpath)));while(data>0&&Response.IsClientConnected){intreadlength=fs.Read(buffer,0,size);Response.OutputStream.Write(buffer,0,readlength);data=data-readlength;}Response.Close();}}
解决方案
解决方案二:
该回复于2012-04-18 15:27:47被版主删除
时间: 2024-10-22 05:58:42