GET LIST OF USB IN WINFORM USING C#?

Aaron Douglas

Total Post:20

Points:140
Posted by  Aaron Douglas
C# 
C#
 2633  View(s)
Ratings:
Rate this:

I have tried the below line of code to get the USB devices from the computer.

 foreach (DriveInfo driveInfo in DriveInfo.GetDrives())
 {
     if (driveInfo.DriveType == DriveType.Removable)
     {
        comboBoxUSB.Items.Add(driveInfo.Name);
     }
 }

comboBoxUSB is a combobox.. here i am getting this :

 E:/
 G:/

but not getting the device name, like :

 E:/Mindstick 

something like this, how can i get this? is it possible to get this?

please help!

  1. Brad Pitt

    Post:61

    Points:429
    Re: Get list of USB in winform using c#?

    foreach (DriveInfo driveInfo in DriveInfo.GetDrives())
     {
         if (driveInfo.DriveType == DriveType.Removable)
         {
            if (drive.IsReady)
                     comboBoxUSB.Items.Add(driveInfo.Name + "-" + driveInfo.VolumeLabel);                                             
         }
     }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!