24.6.08

How to Get Local Disk Space

NameSpace:
using System.Management;

/**Add System.Management as reference from .Net component**/
ManagementObject diskSize = new ManagementObject("win32_logicaldisk.deviceid=\"" + DiveName+ "\"");
diskSize.Get();
string DS = "Disk Space in " + Path[0] + " is :" + diskSize["Size"] + " bytes";
string FS = "Free space in " + Path[0] + " is :" + diskSize["FreeSpace"] + " bytes";

double FreeSpac = Convert.ToDouble(diskSize["FreeSpace"]);

No comments: