title: Finding correct filesize over 4gb in windows
body: <p>I have used this c++ code to find the filesize of some files in windows(using visual studio):</p>
  
  <pre><code>(p_findFileData-&gt;nFileSizeHigh * MAXDWORD) + p_findFileData-&gt;nFileSizeLow);
  </code></pre>
  
  <p>This did not give me the correct filesize if the file was greater than 4gb. After some research I tried:</p>
  
  <pre><code>(p_findFileData-&gt;nFileSizeHigh * (MAXDWORD+1)) + p_findFileData-&gt;nFileSizeLow); 
  </code></pre>
  
  <p>as I read that nfilesizehigh and nfilesizelow are 32 bits each of 64 bit value of the filesize and if the filesize value is greater than 32 bits, we multiply maxdword(which in my case is 0xffffffff) by nfilesizehigh. The second solution also did not work and gave me a smaller size than what it was. I again tried this:</p>
  
  <pre><code>ULONGLONG FileSize = (FindFileData.nFileSizeHigh * 4294967296) + FindFileData.nFileSizeLow;
  </code></pre>
  
  <p>and it worked. Also I used another solution to get the file size too along with this:</p>
  
  <pre><code> ULONGLONG FileSize = FindFileData.nFileSizeHigh;
   FileSize &lt;&lt;= sizeof( FindFileData.nFileSizeHigh ) *8; 
   FileSize |= FindFileData.nFileSizeLow;
  </code></pre>
  
  <p>The above solution works too:</p>
  
  <p>I wanted to know why the first 2 solutions did not work and also the explanation for the last solution if possible as I want to know the internal working of the code. Help would be greatly appreciated.</p>