Hi muhammad12,
Refer below sample.
Code
C#
protected void CheckSpace(object sender, EventArgs e)
{
System.IO.DriveInfo dDrive = new System.IO.DriveInfo("E:\\");
if (dDrive.IsReady)
{
double freeSpacePerc = (dDrive.AvailableFreeSpace / (float)dDrive.TotalSize) * 100;
lblMessage.Text=string.Format("Free space: {0}<br/>Total space: {1}<br/>Percentage free space: {2:0.00}%.",
dDrive.AvailableFreeSpace, dDrive.TotalSize, freeSpacePerc);
}
}
VB.Net
Protected Sub CheckSpace(ByVal sender As Object, ByVal e As EventArgs)
Dim dDrive As IO.DriveInfo = New IO.DriveInfo("E:\")
If dDrive.IsReady Then
Dim freeSpacePerc As Double = (dDrive.AvailableFreeSpace / CSng(dDrive.TotalSize)) * 100
lblMessage.Text = String.Format("Free space: {0}<br/>Total space: {1}<br/>Percentage free space: {2:0.00}%.",
dDrive.AvailableFreeSpace, dDrive.TotalSize, freeSpacePerc)
End If
End Sub
Screenshot