Convert large files in byte[] to store in SQL Server (C#)
<p>I have a file with a size of approx 1.6 GB. I am aware of <a href="https://stackoverflow.com/questions/4557392/storing-large-files-in-sql-server">storing large file in SQL Server</a>. But I have a requirement to generate the blob for this large file.</p>

<p>I am using following code to generate the <code>byte[]</code> for the large file:</p>

<pre><code>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();
</code></pre>

<p>It is throwing </p>

<blockquote>
  <p>An exception of type 'System.OutOfMemoryException' occurred in
  mscorlib.dll but was not handled in user code</p>
</blockquote>

<p>I want to know that How can I convert this large file to <code>byte[]</code>?</p>