کد بدست اوردن فضای خالی یک درایو در سی شارپ:

[CSHARP]using System.Management;[/CSHARP]

[CSHARP]public double GetHDDFreeSpace(string drive) { //check to see if the user provided a drive letter //if not default it to "C" if (drive == "" || drive == null) { drive = "C"; } //create our ManagementObject, passing it the drive letter to the //DevideID using WQL ManagementObject disk = new ManagementObject("Win32_LogicalDisk.DeviceID="" + drive + ":""); //bind our management object disk.Get(); //return the free space amount return Convert.ToDouble(disk["FreeSpace"]); }[/CSHARP]