9

I need to get the free space of a Network drive, without "map drive"

DriveInfo drvInfo = new DriveInfo("\\NetworkDrive");

I try to do this but it does not work.

Hiyasat
  • 8,601
  • 7
  • 33
  • 59
  • See http://stackoverflow.com/questions/676734/net-driveinfo-with-unc-paths - DriveInfo doesn't work with UNC paths (it even specifies that in the help). Try @Mitch's suggstion. – Donnie Jun 03 '10 at 12:16

2 Answers2

9

I believe you will need to call GetDiskFreeSpace (Win32 API) via P/Invoke to get the disk free space of a UNC network drive.

e.g.

C# GetDiskFreeSpace UNC

Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541
0

You could use WMI to connect to the remote computer and display the free space for each drive.

An example can be found here

codingbadger
  • 42,678
  • 13
  • 95
  • 110