0

I'm looking for a way to get disk size information in two cycles, but I'm having difficulty. TotalFreeSpace not recognized.

List<string> NamesDrive = new List<string>();
string[] LogicalDrives = System.IO.Directory.GetLogicalDrives();
foreach (string Disk in LogicalDrives)
{
    NamesDrive.Add(Disk);
}

DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
    foreach (string i in NamesDrive)
    {
        if (d.Name == i)
        {
            string Size = d.TotalFreeSpace;
        }
    }
}

1 Answers1

0

After placing this code in my own IDE, the error is not that the property TotalFreeSpace is not recognized. It says you cannot implicitly cast long to string.

Solution would be:

string Size = d.TotalFreeSpace.ToString();