K
kaczmar2
I have code like so:
FileStream fs = new FileStream(locationTextBox.Text, FileMode.Open,
FileAccess.Write, FileShare.Read);
long size = fs.Length;
byte[] buffer = new byte[size];
// Get file to byte array
fs.Position = 0;
fs.Write(buffer, 0, buffer.Length);
fs.Close();
which works just fine for small/medium sized files. However, if I have
large files (> 2GB) this fails. I get an "arithmetic overflow" error on
the line
byte[] buffer = new byte[size];
if "size" is large, like 2678614016 bytes.
Is there a better way to read in large files?
Thanks,
Christian
FileStream fs = new FileStream(locationTextBox.Text, FileMode.Open,
FileAccess.Write, FileShare.Read);
long size = fs.Length;
byte[] buffer = new byte[size];
// Get file to byte array
fs.Position = 0;
fs.Write(buffer, 0, buffer.Length);
fs.Close();
which works just fine for small/medium sized files. However, if I have
large files (> 2GB) this fails. I get an "arithmetic overflow" error on
the line
byte[] buffer = new byte[size];
if "size" is large, like 2678614016 bytes.
Is there a better way to read in large files?
Thanks,
Christian