Results 1 to 3 of 3

Thread: detect USB drive

  1. #1
    Garcíarobine is offline Senior Member
    Join Date
    Dec 2009
    Posts
    334
    Rep Power
    3

    Default detect USB drive

    Hi .I am second year BSc(I.T). I am learning VB.net programming language. I want to write code to detect USB drive. I tried various codes but none of them worked out. If you are having any suggestions then reply me. It can helpful to me.

  2. #2
    RodríguezBrown is offline Senior Member
    Join Date
    Dec 2009
    Posts
    322
    Rep Power
    3

    Default

    You will require WMI for this. It will give you permit to specify all removable devices in the system and query their properties like label, serial number etc. If you would like warning of when a drive is connected, WMI should be able to handle that also. There is an outstanding WMI plug-in for the server explorer in VS.NET available free on the Microsoft website; it will help in wiring up event code for WMI classes.

  3. #3
    WilsonMartin is offline Senior Member
    Join Date
    Dec 2009
    Posts
    319
    Rep Power
    3

    Default

    Try to understand following code which is helpful for you. Put a Button, Textbox and a Listbox on a form and use the following:
    Code:
    Imports System.Reflection
    
    Imports System.IO
    
    Public Class Form1
    
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    ' Find the first removable storage device and make this the initial
    
    ' directory if it exists
    
    Dim allDrives() As IO.DriveInfo = IO.DriveInfo.GetDrives()
    
    Dim d As IO.DriveInfo
    
    For Each d In allDrives
    
    If d.IsReady = True AndAlso d.DriveType = IO.DriveType.Removable Then
    
    ListBox1.Items.Add(d.VolumeLabel).ToString()
    
    If IO.DriveType.Removable Then
    
    TextBox1.Text = d.AvailableFreeSpace
    
    End If
    
    Else
    
    If d.IsReady = True And Not d.DriveType = DriveType.Removable Then
    
    ListBox1.Items.Add(d.RootDirectory).ToString()
    
    TextBox1.Text = d.AvailableFreeSpace
    
    End If
    
    End If
    
    Next
    
    End Sub
    
    End Class

Similar Threads

  1. Messenger Detect
    By Harrison Cruz in forum Download Tools and Softwares
    Replies: 0
    Last Post: 11-03-2010, 09:42 PM
  2. Can’t detect DVD drive in Vista
    By MartinWilson in forum Windows Vista
    Replies: 2
    Last Post: 03-22-2010, 03:33 PM
  3. Unable to detect Internal Hard drive
    By PerryCollins in forum Hard Disk
    Replies: 2
    Last Post: 03-12-2010, 03:06 PM
  4. Vista doesn’t detect Blu-ray Drive
    By MyersGray in forum Windows Vista
    Replies: 3
    Last Post: 02-25-2010, 02:09 PM
  5. Not able to detect virus on pen drive
    By EvansMitchell in forum Optical Drives
    Replies: 2
    Last Post: 02-20-2010, 11:38 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48