I need to upload large files of at least 1GB
file size.
I am using ASP.Net
, C#
and IIS 5.1
as my development platform.
Try copying without loading every thing in the memory :
public void CopyFile()
{
Stream source = HIF.PostedFile.InputStream; //your source file
Stream destination = File.OpenWrite(filePath); //your destination
Copy(source, destination);
}
public static long Copy(Stream from, Stream to)
{
long copiedByteCount = 0;
byte[] buffer = new byte[2 << 16];
for (int len; (len = from.Read(buffer, 0, buffer.Length)) > 0; )
{
to.Write(buffer, 0, len);
copiedByteCount += len;
}
to.Flush();
return copiedByteCount;
}
Setting maxRequestLength should be enough for uploading files larger than 4mb, which is the default limit for HTTP request size. Please make extra sure that nothing is overriding your config file.
Alternatively you can check the async upload provided by Telerik, which uploads files by 2mb chunks and effectively can bypass the ASP.NET request size limitation.