5 Replies - 1012 Views - Last Post: 28 December 2012 - 07:06 AM Rate Topic: -----

#1 HeBTeMy  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 299
  • Joined: 05-October 12

usb detector

Posted 26 December 2012 - 12:01 PM

Hi, i have an application that detects a drive being inserted with this code:

Dim driveNames As New List(Of String)
        For Each drv As System.IO.DriveInfo In System.IO.DriveInfo.GetDrives
            If drv.DriveType = IO.DriveType.Removable AndAlso drv.IsReady Then
                Dim drvLetter As String = drv.Name
                'Dim drvVolume As String = drv.VolumeLabel
                ' Dim drvSpaceAvailable As String = ShowTotalFileSize(drv.AvailableFreeSpace)
                If ListBox1.Items.IndexOf(drv.Name) = -1 Then
                    If ListBox2.Items.IndexOf(drv.Name) = -1 Then
                        MsgBox(drv.Name & " has been detected.", MsgBoxStyle.Information, "New Drive")
                        ListBox2.Items.Add(drv.Name)
                    End If
                End If
            End If
        Next



But it doesn't show the name of the drive... only the driveletter like G:\, how can i identify each drive? Like it's name or something... ?

Is This A Good Question/Topic? 0
  • +

Replies To: usb detector

#2 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5388
  • View blog
  • Posts: 27,384
  • Joined: 10-May 07

Re: usb detector

Posted 26 December 2012 - 12:04 PM

I would look under the Windows API for Volume Management Functions.
Was This Post Helpful? 0
  • +
  • -

#3 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 769
  • Joined: 19-October 11

Re: usb detector

Posted 26 December 2012 - 01:21 PM

Try with drv.VolumeLabel. Edit: I missed your commented code. What happens if you uncomment it?

This post has been edited by lucky3: 26 December 2012 - 01:22 PM

Was This Post Helpful? 0
  • +
  • -

#4 HeBTeMy  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 299
  • Joined: 05-October 12

Re: usb detector

Posted 27 December 2012 - 11:47 AM

View Postlucky3, on 26 December 2012 - 01:21 PM, said:

Try with drv.VolumeLabel. Edit: I missed your commented code. What happens if you uncomment it?


Didnt understand what you said... im on cell, i cant test it now.
Sent from my X8 using Tapatalk 2

This post has been edited by no2pencil: 27 December 2012 - 11:48 AM
Reason for edit:: ** Removed double post **

Was This Post Helpful? 0
  • +
  • -

#5 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 769
  • Joined: 19-October 11

Re: usb detector

Posted 27 December 2012 - 12:12 PM

Line 5 of your posted code: if you uncomment it and use it, you'll have the drive label (name) in drvVolume variable.

This post has been edited by lucky3: 27 December 2012 - 12:13 PM

Was This Post Helpful? 1
  • +
  • -

#6 HeBTeMy  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 299
  • Joined: 05-October 12

Re: usb detector

Posted 28 December 2012 - 07:06 AM

Yws it shows, thanks... my mistake.
Appreciated
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1