当前位置:编程学习 > C#/ASP.NET >>

Asp.NET大文件上传开发总结(二)

为了提供文件内容,我们需要首先需确定客户请求中发送的有文件内容,然后确定文件内容的位置。这部分对应的代码如下:

1HttpApplication app = sender as HttpApplication;
2            HttpWorkerRequest request = GetWorkerRequest(app.Context);
3           
4            if (!IsUploadRequest(app.Request)) return; //不是文件上传,则退出
5           
6            string sContentType = app.Request.ContentType.ToLower();
7            byte[] arrBoundary = GetMultipartBoundary(sContentType);
8            int ContentLength = app.Request.ContentLength; //信息体的总长度
9
10            DataReader dataReader = new DataReader(app.Context.Request.ContentEncoding,

arrBoundary);
11            DateTime startDate = DateTime.Now;
12            byte[] arrBuffer = request.GetPreloadedEntityBody();
13            if (arrBuffer == null)
14            {
15                arrBuffer = new Byte[0];
16                tempFile.Close();
17                return; //没有读取到信息体
18            }
19            else
20        &

<
补充:asp.net教程,.Net开发 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,