Using this example on how to get the UNC path, you can simply return the FreeSpace property, I changed the code below:
ManagementPath path = new ManagementPath(@"\" + System.Environment.MachineName + @"\root\cimv2"); ObjectQuery query = new ObjectQuery("select * from Win32_LogicalDisk WHERE DriveType = 4"); ManagementScope scope = new ManagementScope(path, new ConnectionOptions()); ManagementObjectSearcher search = new ManagementObjectSearcher(scope, query); foreach (ManagementObject o in search.Get()) { Console.WriteLine(o.Properties["FreeSpace"].Value.ToString()); }
taylonr Jan 12 2018-10-12 16:28
source share