title: Get size of file on disk
body: <pre><code>var length = new System.IO.FileInfo(path).Length;
  </code></pre>
  
  <p>This gives the logical size of the file, not the size on the disk. </p>
  
  <p>I wish to get the size of a file on the disk in C# (preferably without <em>interop</em>) as would be reported by Windows Explorer.</p>
  
  <p>It should give the correct size, including for:</p>
  
  <ul>
  <li>A compressed file</li>
  <li>A sparse file</li>
  <li>A fragmented file</li>
  </ul>