title: MemoryStream, how many bytes in kb?
body: <p>I'm using .net core to upload an image file. The file is converted to a MemoryStream and then sent to a service which will validate the file. Currently I do that with something like this:</p>
  
  <pre><code>MemoryStream stream = GetMemoryStream();
  var fileSize = stream.length;
  </code></pre>
  
  <p>Now I want to ensure that the image is not larger than 512 kb. My problem is that I'm not sure what value to use to convert to bytes, 1024 or 1000? Should I use the decimal or binary values when listing length from MemoryStream?</p>
  
  <p>Which scenario is correct?</p>
  
  <p>Scenario A</p>
  
  <pre><code>if(fileSize &gt; 512000) return false;
  </code></pre>
  
  <p>Scenario B</p>
  
  <pre><code>if(fileSize &gt; 524288) return false;
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>When I look at properties of an image on my desktop and it says 512KB. Which scenario did the computer use to calculate that size?</p>