title: how to calculate the file size in C#
body: <p>In my asp mvc 3 application, I have an action which allows the user to download a given file. </p>
  
  <p>Here is the code :</p>
  
  <pre><code>public FilePathResult DownloadFile(string fileName)
      {
          try
          {
              string uploadsDocumentPath = System.Configuration.ConfigurationManager.AppSettings["uploadsDocumentPath"].ToString();
              string ext = Path.GetExtension(fileName).ToLower();
              Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext); // henter info fra windows registry
              if (regKey != null &amp;&amp; regKey.GetValue("Content Type") != null)
              {
                  mimeType = regKey.GetValue("Content Type").ToString();
              }
  
              return File(uploadsDocumentPath + fileName, mimeType, fileName);
          }
          catch (Exception)
          {
  
              throw;
          }
      }
  </code></pre>
  
  <p>I want to be able to allow only files with size less than 150MB to be downloaded. But I can't find how to calculate this type of file's size.</p>
  
  <p>Any ideas ?</p>