I have a file with a size of approx 1.6 GB. I am aware of storing large file in SQL Server. But I have a requirement to generate the blob for this large file.
I am using following code to generate the byte[]
for the large file:
string filePath = Server.MapPath(filename);
string filename = Path.GetFileName(filePath);
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
Byte[] bytes = br.ReadBytes((int)fs.Length);
br.Close();
fs.Close();
It is throwing
An exception of type 'System.OutOfMemoryException' occurred in mscorlib.dll but was not handled in user code
I want to know that How can I convert this large file to byte[]
?