This is a very simple C# code snippet which allows you to display the Hard Disk info such as Total disk storage and Free Disk space on your machine. I found this intersting since it reveals a bit of local machine’s info through a browser.
Here goes the code.
public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
ManagementObject disk = new ManagementObject(“win32_logicaldisk.deviceid=\”c:\””);
Response.Write(“Logical Disk Space = ” + disk[“Size”] + “bytes. “);
Response.Write(“Free space on C:\\ is ” + disk[“FreeSpace”] + ” bytes. “);
As you can see a Management object is created specifying the System Drive. You can access to its properties by the index of the Management Object. ex:- disk[“Size”] will give you the Total size of the drive.