Namespace:
using System.IO;
And the function:
string GetDriveInfo(string strfile)
{
string strInfo;
strInfo = "";//initialize string
try
{
FileInfo file = new FileInfo(strfile);
DriveInfo driveinfo = new DriveInfo(file.FullName);
strInfo += "Drive: " + driveinfo.Name;
if (driveinfo.IsReady)
{
strInfo += "\nFree space: " + driveinfo.AvailableFreeSpace.ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
return strInfo;
}
Function usage:
MessageBox.Show(GetDriveInfo("C:/"));
That's it!




