long Length = Reader.Length;
HttpContext.Current.Response.Buffer = false;
HttpContext.Current.Response.AddHeader("Connection", "Keep-Alive");
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.Charset = "utf-8";
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(fileName));
HttpContext.Current.Response.AddHeader("Content-Length", Length.ToString());
byte[] Buffer = new Byte[10000];//存放欲发送数据的缓冲区
int ByteToRead; //每次实际读取的字节数
while (Length0)
{
//剩余字节数不为零,继续传送
if (HttpContext.Current.Response.IsClientConnected)
{
//客户端浏览器还打开着,继续传送
ByteToRead = Reader.Read(Buffer, 0, 10000);//往缓冲区读入数据
HttpContext.Current.Response.OutputStream.Write(Buffer, 0, ByteToRead);
//把缓冲区的数据写入客户端浏览器
HttpContext.Current.Response.Flush(); //立即写入客户端
Length -= ByteToRead;//剩余字节数减少}
else
{
//客户端浏览器已经断开,阻止继续循环
Length = -1;
}
}//关闭该文件
Reader.Close();
}
QQ:121一九五五121
vb.net下载文件的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vb 下载文件到指定目录、vb.net下载文件的信息别忘了在本站进行查找喔 。
- mongodb 更新子文档 mongodb数据文件无法新建
- mongodb存储文件如何存储 mongodb海量图片存储
- mongodb存储图片和文件实践 mongodb存文件和表
- mysql 输出格式 mysql输出到文件位置
- mongodb安装包下载 MongoDB下载安装
- mongodb keyfile mongodb可执行文件路径怎么修改
- mongodb下载安装教程 mongodb怎么下载安装
- redis的ae.c文件 redis的ae.c
- mongodb安装包下载 mongodb安装包大小
- mongodb数据库文件迁移 mongodb迁移到其他目录
