title: Read large file into byte array and encode it to ToBase64String
body: <p>I have implemented POC to read entire file content into Byte[] array. I am now succeeded to read files whose size below 100MB, when I load file whose size more than 100MB then it is throwing </p>
  
  <blockquote>
    <p>Convert.ToBase64String(mybytearray)   Cannot obtain value of the
    local variable or argument because there is not enough memory
    available.</p>
  </blockquote>
  
  <p>Below is my code that I have tried to read content from file to Byte array</p>
  
  <pre><code>var sFile = fileName;
  var mybytearray = File.ReadAllBytes(sFile);
  
  var binaryModel = new BinaryModel
  {
      fileName = binaryFile.FileName,
      binaryData = Convert.ToBase64String(mybytearray),
      filePath = string.Empty
  };
  </code></pre>
  
  <p>My model class is as below</p>
  
  <pre><code>public class BinaryModel
  {
      public string fileName { get; set; }
      public string binaryData { get; set; }
      public string filePath { get; set; }
  }
  </code></pre>
  
  <p>I am getting "Convert.ToBase64String(mybytearray) Cannot obtain value of the local variable or argument because there is not enough memory available." this error at Convert.ToBase64String(mybytearray).</p>
  
  <p>Is there anything which I need to take care to prevent this error?</p>
  
  <p><em>Note: I do not want to add line breaks to my file content</em></p>