NB----NB大牛------请进-----下载大小问题
这几天一直折腾下载的一个东西,一直有下载不了大文件的念头闪烁,今天终于深测了下。发现文件大概到了600多M的时候,客户端就没反应了,一直响应着。服务器端日志显示下载完成
下面贴上源码:
System.IO.Stream iStream = null;
// Buffer to read 10K bytes in chunk:
byte[] buffer = new Byte[10000];
// Length of the file:
int length;
// Total bytes to read:
long dataToRead;
// Identify the file to download including its path.
string filepath = fileName + ".zip";
// Identify the file name.
string filename = System.IO.Path.GetFileName(filepath);
Logger.Log.Info("文件名:"+filename);
try
{
// Open the file.
iStream = new System.IO.FileStream(filepath, System.IO.FileMode.Open,
System.IO.FileAccess.Read, System.IO.FileShare.Read);
// Total bytes to read:
dataToRead = iStream.Length;
Logger.Log.Info("大小:" + dataToRead);
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename="+Server.UrlEncode(filename));
// Read the bytes.
while (dataToRead > 0)
{
// Verify that the client is connected.
if (Response.IsClientConnected)
{
// Read the data in buffer.
length = iStream.Read(buffer, 0, 10000);
Logger.Log.Info("大小length:" + length);
// Write the data to the current output stream.
Response.OutputStream.Write(buffer, 0, length);
// Flush the data to the HTML output.
Response.Flush();
buffer = new Byte[10000];
dataToRead = dataToRead - length;
}
else
{
//prevent infinite loop if user disconnects
dataToRead = -1;
}
}
Logger.Log.Info("下载成功!");
}
catch (Exception ex)
{
// Trap the error, if any.
Logger.Log.Info("异常:" + ex.ToString());
//Response.Write("Error : " + ex.Message);
}
finally
{
if (iStream != null)
{
//Close the file.
iStream.Close();
}
}
日志:
INFO ,12-03-21 13:31:20,Page_Load,页面加载中........
INFO ,12-03-21 13:31:20,Page_Load,执行文件打包操作
INFO ,12-03-21 13:31:21,ForeignFileToZIP,执行SP_RPT_GETFILEDOWNLOAD获取文件的信息900
INFO ,12-03-21 13:31:21,ForeignFileToZIP,执行SP_RPT_GetFilesToExcel获取说明文档信息900
INFO ,12-03-21 13:31:21,ForeignFileToZIP,创建文件夹D:\download\外来文件_31868e20-3a43-419d-b6f4-39425736f2d4\外来文件
INFO ,12-03-21 13:31:21,ToExcel,生成说明文档
INFO ,12-03-21 13:31:24,SetExcelTitle,设置说明文档EXCEL的表头
INFO ,12-03-21 13:31:58,ForeignFileToZIP,说明文档生成完成,存放:D:\download\外来文件_31868e20-3a43-419d-b6f4-39425736f2d4\外来文件\外来文件.xls
INFO ,12-03-21 13:31:58,ForeignFileToZIP,读取文件,整理文件存放目录
INFO ,12-03-21 13:32:34,ForeignFileToZIP,压缩文件
INFO ,12-03-21 13:36:02,ForeignFileToZIP,下载成功
INFO ,12-03-21 13:36:02,ForeignFileToZIP,文件名:外来文件.zip
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小:756758941
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:45:21,ForeignFileToZIP,下载成功!
INFO ,12-03-21 13:47:49,Application_Start,ASP.global_asax,Application_Start
INFO ,12-03-21 13:47:49,Application_Start,ASP.global_asax,IsCache:true
下面贴上源码:
System.IO.Stream iStream = null;
// Buffer to read 10K bytes in chunk:
byte[] buffer = new Byte[10000];
// Length of the file:
int length;
// Total bytes to read:
long dataToRead;
// Identify the file to download including its path.
string filepath = fileName + ".zip";
// Identify the file name.
string filename = System.IO.Path.GetFileName(filepath);
Logger.Log.Info("文件名:"+filename);
try
{
// Open the file.
iStream = new System.IO.FileStream(filepath, System.IO.FileMode.Open,
System.IO.FileAccess.Read, System.IO.FileShare.Read);
// Total bytes to read:
dataToRead = iStream.Length;
Logger.Log.Info("大小:" + dataToRead);
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename="+Server.UrlEncode(filename));
// Read the bytes.
while (dataToRead > 0)
{
// Verify that the client is connected.
if (Response.IsClientConnected)
{
// Read the data in buffer.
length = iStream.Read(buffer, 0, 10000);
Logger.Log.Info("大小length:" + length);
// Write the data to the current output stream.
Response.OutputStream.Write(buffer, 0, length);
// Flush the data to the HTML output.
Response.Flush();
buffer = new Byte[10000];
dataToRead = dataToRead - length;
}
else
{
//prevent infinite loop if user disconnects
dataToRead = -1;
}
}
Logger.Log.Info("下载成功!");
}
catch (Exception ex)
{
// Trap the error, if any.
Logger.Log.Info("异常:" + ex.ToString());
//Response.Write("Error : " + ex.Message);
}
finally
{
if (iStream != null)
{
//Close the file.
iStream.Close();
}
}
日志:
INFO ,12-03-21 13:31:20,Page_Load,页面加载中........
INFO ,12-03-21 13:31:20,Page_Load,执行文件打包操作
INFO ,12-03-21 13:31:21,ForeignFileToZIP,执行SP_RPT_GETFILEDOWNLOAD获取文件的信息900
INFO ,12-03-21 13:31:21,ForeignFileToZIP,执行SP_RPT_GetFilesToExcel获取说明文档信息900
INFO ,12-03-21 13:31:21,ForeignFileToZIP,创建文件夹D:\download\外来文件_31868e20-3a43-419d-b6f4-39425736f2d4\外来文件
INFO ,12-03-21 13:31:21,ToExcel,生成说明文档
INFO ,12-03-21 13:31:24,SetExcelTitle,设置说明文档EXCEL的表头
INFO ,12-03-21 13:31:58,ForeignFileToZIP,说明文档生成完成,存放:D:\download\外来文件_31868e20-3a43-419d-b6f4-39425736f2d4\外来文件\外来文件.xls
INFO ,12-03-21 13:31:58,ForeignFileToZIP,读取文件,整理文件存放目录
INFO ,12-03-21 13:32:34,ForeignFileToZIP,压缩文件
INFO ,12-03-21 13:36:02,ForeignFileToZIP,下载成功
INFO ,12-03-21 13:36:02,ForeignFileToZIP,文件名:外来文件.zip
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小:756758941
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:36:02,ForeignFileToZIP,大小length:10000
INFO ,12-03-21 13:45:21,ForeignFileToZIP,下载成功!
INFO ,12-03-21 13:47:49,Application_Start,ASP.global_asax,Application_Start
INFO ,12-03-21 13:47:49,Application_Start,ASP.global_asax,IsCache:true
...全文
相关推荐
nboot通过串口下载并运行eboot.nb0.pdf
- **下载文件大小调整**:实际下载的文件大小通过 `fileSize-6` 计算得出,其中减去的 6 字节包括用于记录文件大小的 4 字节和用于记录校验码的 2 字节。
nb-iot nb73,nb75模块资料
在实际部署过程中,用户可以下载相关手册和示例代码,通过这些资料来更好地利用NB75模块进行物联网开发和应用。这些资料覆盖了模块的使用、配置、编程等多个方面,为开发者提供了丰富的参考信息。
基于窄带物联网技术的远传压力变送器在大牛地气田的试验效果评价.pdf
鉴于此,研究团队希望利用基于NB-IoT技术的远传压力变送器来实现气井数据的信息化改造。试验设计包括了对大牛地气田采气管理一区进行NB网络信号的覆盖情况评估和单井井口数据的远传效果评价。
基于窄带物联网技术的远传压力变送器在大牛地气田的试验效果评价.zip
本文将探讨在大牛地气田中,基于NB-IoT技术的远传压力变送器的试验效果及其评价。一、NB-IoT技术基础1. 技术特点:NB-IoT技术具备深覆盖、大连接、低功耗三大优势。
NB-IoT BC95 开发手册下载
**测试与优化**:介绍如何进行模块的功能测试、性能测试,以及在遇到问题时如何进行故障排查和优化,确保产品的稳定运行。7.


