How can I get drive information from C #?

0

Good afternoon, I was asked to carry out a project that can fetch information from the drives ( C: , D: , such as how many drives there are, the name of each one, the total space and the space used.

But I do not know how I'll get this information. Can anyone help me?

    
asked by anonymous 26.06.2018 / 15:51

1 answer

4

You can use the class DriveInfo to get information about the drives.

static void Main(string[] args)
{
    var drives = DriveInfo.GetDrives();
    foreach (DriveInfo info in drives)
    {
          Console.WriteLine("Nome: {0}\nTamanho: {1}\nTipo de particao: {2}", info.Name, info.TotalSize, info.DriveFormat);
    }
     Console.ReadLine();
}
    
26.06.2018 / 16:05