title: C# - Creating byte array of unknown size?
body: <p>I'm trying to create a class to manage the opening of a certain file. I would one of the properties to be a byte array of the file, but I don't know how big the file is going to be. I tried declaring the byte array as :</p>
  
  <pre><code>public byte[] file;
  </code></pre>
  
  <p>...but it won't allow me to set it the ways I've tried. br is my BinaryReader:</p>
  
  <pre><code>file = br.ReadBytes(br.BaseStream.Length);
  
  br.Read(file,0,br.BaseStream.Length);
  </code></pre>
  
  <p>Neither way works. I assume it's because I have not initialized my byte array, but I don't want to give it a size if I don't know the size. Any ideas?</p>
  
  <p>edit: Alright, I think it's because the Binary Reader's BaseStream length is a long, but its readers take int32 counts. If I cast the 64s into 32s, is it possible I will lose bytes in larger files?</p>