Results 1 to 3 of 3

Thread: VB.Net List All Removable Forms of Storage (e.g Flash Disk)

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2011
    Location
    Sydney, Australia
    Posts
    756

    VB.Net List All Removable Forms of Storage (e.g Flash Disk)

    Hi All,

    Some time back I needed a way to list out what USB storage drives were on the system, I used this as part of a backup program so that a user can plug in a Flash drive or USB HDD etc and the option would show in my program (without the need for openfiledialog control).

    To list the drives see below code, this adds any drives to a FlowLayoutPanel as a button control. the tag is set to the drive path and the text set to the Volume Label or if not present the type of drive, there is also an AddHandler in there so we have a clickable action when the user presses said button (I have not included this as you can use for your purposes).

    Code:
    For Each d As System.IO.DriveInfo In My.Computer.FileSystem.Drives
                If d.DriveType = IO.DriveType.Removable Then
                    Dim asd As New Button
                    asd.Tag = d.ToString
                    If d.VolumeLabel = "" Then
                        asd.Text = d.DriveType.ToString
                    Else
                        asd.Text = d.VolumeLabel.ToString
                    End If
                    AddHandler asd.Button1.Click, AddressOf Me.clickme
                    FlowLayoutPanel1.Controls.Add(asd)
                 End If
    Next
    Enjoy
    My CodeBank Submissions
    • Listbox with transparency and picture support - Click Here
    • Check for a true internet connection - Click Here
    • Open Cash drawer connected to receipt printer - Click Here
    • Custom color and size border around form - Click Here
    • Upload file to website without user logins, includes PHP - Click Here
    • List All Removable USB Storage Devices - Click Here
    • Custom On/Off Slide Control - Click Here
    • Insert multiple rows of data into one database table using parameters - Click Here
    • Trigger USB/Serial Cash Drawer - Click Here

  2. #2
    Banned
    Join Date
    May 2014
    Posts
    7

    Re: VB.Net List All Removable Forms of Storage (e.g Flash Disk)

    how to get the drive letter

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2011
    Location
    Sydney, Australia
    Posts
    756

    Re: VB.Net List All Removable Forms of Storage (e.g Flash Disk)

    Hi from memory that's what the volume label is.
    My CodeBank Submissions
    • Listbox with transparency and picture support - Click Here
    • Check for a true internet connection - Click Here
    • Open Cash drawer connected to receipt printer - Click Here
    • Custom color and size border around form - Click Here
    • Upload file to website without user logins, includes PHP - Click Here
    • List All Removable USB Storage Devices - Click Here
    • Custom On/Off Slide Control - Click Here
    • Insert multiple rows of data into one database table using parameters - Click Here
    • Trigger USB/Serial Cash Drawer - Click Here

Posting Permissions

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



Click Here to Expand Forum to Full Width