Home > Net >  How to get the disk drive name?
How to get the disk drive name?

Time:10-22

String [] DriveNames=Directory. The GetLogicalDrives ();
Can only obtain: C, D, E: this name,
What I want is
Local disk (C:)
Local disk (D:)
Such data
I.e., open the computer after I see the same data,

How to get?

CodePudding user response:

 DriveInfo []. AllDrives=DriveInfo GetDrives (); 

The foreach (DriveInfo d in allDrives)
{
Console. WriteLine (" Drive {0} ", d.N ame);
Console. WriteLine (" Drive type: {0} ", d.D riveType);
If (d.I sReady==true)
{
Console. WriteLine (" Volume label: {0} ", d.V olumeLabel);
Console. WriteLine (" the File system: {0} ", d.D riveFormat);
Console. WriteLine (
"The Available space to the current user: 15} {0, bytes",
Da vailableFreeSpace);

Console. WriteLine (
"The Total available space: 15} {0, bytes",
Which otalFreeSpace);

Console. WriteLine (
"The Total size of the drive: 15} {0, bytes",
Which otalSize);
}
}
  •  Tags:  
  • C#
  • Related