我最近看了许多关于较大文件上传的帖子,其中看到一个用思归的方法来解决大文件的上传问题,如下:[size=24px][/size]
////////////////////////////////////////////////////////////////////////////////////////////////
思归解决的方法是利用隐含的HttpWorkerRequest,用它的GetPreloadedEntityBody 和 ReadEntityBody方法从IIS为ASP.NET建立的pipe里分块读取数据IServiceProvider provider = (IServiceProvider) HttpContext.Current;
HttpWorkerRequest wr = (HttpWorkerRequest) provider.GetService(typeof(HttpWorkerRequest));
byte[] bs = wr.GetPreloadedEntityBody();
....
if (!wr.IsEntireEntityBodyIsPreloaded())
{
int n = 1024;
byte[] bs2 = new byte[n];
while (wr.ReadEntityBody(bs2,n) >0)
{
.....
}
}至今我还是看不懂上边的代码,请各位高手指点迷津……(写一段用思归上传较大文件的代码,最好有注释)。谢谢!!我现在非常需要这个功能,希望各位能帮我这个忙!!![size=24px][/size]
////////////////////////////////////////////////////////////////////////////////////////////////
思归解决的方法是利用隐含的HttpWorkerRequest,用它的GetPreloadedEntityBody 和 ReadEntityBody方法从IIS为ASP.NET建立的pipe里分块读取数据IServiceProvider provider = (IServiceProvider) HttpContext.Current;
HttpWorkerRequest wr = (HttpWorkerRequest) provider.GetService(typeof(HttpWorkerRequest));
byte[] bs = wr.GetPreloadedEntityBody();
....
if (!wr.IsEntireEntityBodyIsPreloaded())
{
int n = 1024;
byte[] bs2 = new byte[n];
while (wr.ReadEntityBody(bs2,n) >0)
{
.....
}
}至今我还是看不懂上边的代码,请各位高手指点迷津……(写一段用思归上传较大文件的代码,最好有注释)。谢谢!!我现在非常需要这个功能,希望各位能帮我这个忙!!![size=24px][/size]
可以用asynchronous或Web Service的方式
http://www.codeproject.com/aspnet/FileHandlerPackage.asp