上传大于 500 MB 的文件时出现以下错误
“抛出了‘System.OutOfMemoryException’类型的异常。”
我的代码如下所示:
public readonly string Filename, ContentType;
public readonly int Size;
public readonly byte[] Bytes;
public FileHolder(HttpPostedFile file)
{
Filename = Path.GetFileName(file.FileName);
ContentType = GetContentType(file.ContentType, Filename);
Size = file.ContentLength;
Bytes = new byte[file.InputStream.Length]; //Here i get error
file.InputStream.Read(Bytes, 0, Size);
}