Finding out total and free disk space in .NET

前端 未结 9 1244
我在风中等你
我在风中等你 2021-01-04 03:08

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 f

9条回答
  •  萌比男神i
    2021-01-04 03:45

    I'm pretty sure this is impossible. In windows explorer, if I try to get the folder properties of a UNC directory, it gives me nothing as far as available space. Used/Available space is a characteristic of drives, not folders, and UNC shares are treated as just folders.

    you have to either:
    - Map a drive
    - Run something on the remote machine to check disk space.

    You could also run into problems with something like Distributed file system, in which a UNC/Mapped share is NOT tied to any specific drive, so there youd have to actually sum up several drives.

    And what about user quotas? The drive may not be full, but the account you are using to write to that folder may have hit its limit.

提交回复
热议问题