How to get Drive Letter and Name (volume label)

前端 未结 2 2023
旧时难觅i
旧时难觅i 2021-02-08 03:16

I have a program that tells me all the hard disks/ usb\'s, but it only tells me the drive letter not the name. Here is what I have:

DriveInfo[] drives = DriveIn         


        
2条回答
  •  轮回少年
    2021-02-08 04:11

    You are looking for the VolumeLabel property:

    http://msdn.microsoft.com/en-us/library/system.io.driveinfo.volumelabel.aspx

    Example:

    Console.WriteLine(drives[i].VolumeLabel);
    

提交回复
热议问题