我在 Visual Studio 2010 中使用 Dropnet 库,并将我的项目与 Dropbox 连接起来。当我尝试对小于 4MB 的文件使用上传时,没关系,但当文件较大时,就会出现问题。我已经搜索并找到了一个解决方案,在 web.config 中添加此代码:
<system.web>
<httpRuntime executionTimeout="1000" maxRequestLength="104857600"/>
</system.web>
和这个:
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="104857600"/>
</requestFiltering>
</security>
</system.webServer>
所以这应该允许我上传小于 100MB 的文件,我已经成功处理了一些大约 10MB 的文件,但是当我尝试大约 50MB 或更小的文件时,它会以某种方式卡住,没有错误或任何东西,无论我输入什么数字 maxRequestLength 和maxAllowedContentLength 还是一样的。请帮忙。我的代码是:
if (filMyFile.PostedFile!=null)
{
Stream stream = filMyFile.PostedFile.InputStream;
int sLen = filMyFile.PostedFile.ContentLength;
byte[] binaryData = new byte[sLen];
int n = stream.Read(binaryData, 0, sLen);
_client.UploadFile("/Folder/", filMyFile.PostedFile.FileName, binaryData);
}