the only way that i know of is:
when the user inserts a flash card or plugs in a flash drive the OS gives it a logical drive (listed in My Computer)
so what i do is when the app starts (the flash drive needs to be un-pluged) it grabs a list of all the current logical drives and stores them in a string array
then i have a timer that every 300 miliseconds it gets a list of all the logical drives and stores them in a new string array variable then compairs the two and if it produces a -1 (meaning theres a drive in the new variable that's not in the original one, meaning the user plugged in a flash drive)
which means i know what the drive letter is for that flash drive too and i store that in a different variable, here's the code i use:
Code:
Private strDrives() As String = Environment.GetLogicalDrives
Private strFlashDrive As String
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tmrDrives.Enabled = True
End Sub
Private Sub tmrDrives_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrDrives.Tick
Dim CurrentDrives() As String = Environment.GetLogicalDrives
For Each Drive As String In CurrentDrives
If strDrives.IndexOf(strDrives, Drive) = -1 Then
tmrDrives.Enabled = False
strFlashDrive = Drive
End If
Next Drive
End Sub
Bookmarks