1 / 7
文档名称:

asp.netmvc如何实现文件下载.doc

格式:doc   大小:33KB   页数:7页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

asp.netmvc如何实现文件下载.doc

上传人:学习好资料 2021/7/25 文件大小:33 KB

下载得到文件列表

asp.netmvc如何实现文件下载.doc

相关文档

文档介绍

文档介绍:
public static bool DownloadFile(HttpContext httpContext, string filePath, long speed)
{
bool ret = true;
try
{
#region--验证:HttpMethod,请求的文件是否存在
switch (())
{ //目前只支持GET和HEAD方法
case "GET":
case "HEAD":
break;
default:
= 501;
return false;
}
if (!(filePath))
{
= 404;
return false;
}
#endregion

#region 定义局部变量
long startBytes = 0;
int packSize = 1024 * 10; //分块读取,每块10K bytes
string fileName = (filePath);
FileStream myFile = new FileStream(filePath, , , );
BinaryReader br = new BinaryReader(myFile);
long fileLength = ;

int sleep = (int)( * packSize / speed);//毫秒数:读取下一数据块的时间间隔
string lastUpdateTiemStr = (filePath).ToString("r");
string eTag = (fileName, ) + lastUpdateTiemStr;//便于恢复下载时提取请求头;
#endregion