title: Finding out total and free disk space in .NET
body: <p>I am trying to find a way to determine the total and available disk space in an arbitrary folder from a .NET app. By "total disk space" and "available disk space" in a folder I refer to the total and available disk space that this folder would report if you performed a "dir" command on it, that is, the total and available disk space of the logical drive containing that folder, considering the user account under which the request is being made.</p>
  
  <p>I am using C#. The method should work both for local and remote folders given as UNC paths (rather than accessed through mapped drive letters). For example, it should work for:</p>
  
  <ul>
  <li>C:\Temp</li>
  <li>\\Silfen\Resources\Temp2</li>
  </ul>
  
  <p>I am starting with a DirectoryInfo object, but this seems to have no associated disk space information. The DriveInfo class does, but it won't work with remote folders.</p>
  
  <p><strong>Edit.</strong> After some exchanges with you guys, I am considering mapping remote folders as local drives, using DriveInfo to obtain the data, and unmapping again. The problem with this approach is that my app needs to collect the data for over 120 folders a few times a day, every day. I am not sure this would be feasible.</p>
  
  <p>Any ideas? Thanks.</p>