I tried to read a 2+ gb file in two ways, the first:
var file = File.ReadAllBytes(filepath);
returns an exception, file over 2gb.
Second way:
var file = ReadAllBytes(filepath);
public byte[] ReadAllBytes(string fileName)
{
byte[] buffer = null;
using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
{
buffer = new byte[fs.Length];
fs.Read(buffer, 0, (int)fs.Length);
}
return buffer;
}
Exception: "Array dimensions exceeded supported range." My goal is to send the file in the body of http request (using WebClient class).
Any example of how to read large files?
Thanks