Free VB.NET Code Snippets, Source Code, Articles, Examples, Tutorials and Programming Help

Get Drive Type in VB.NET

        Dim Drives() As DriveInfo = DriveInfo.GetDrives()
        Dim Builder As New System.Text.StringBuilder

        Dim Info As DriveInfo
        For Each Info In Drives
            Builder.Append("Drive name " & Info.Name & Environment.NewLine)
            Builder.Append("  Drive type " & Info.DriveType.ToString & Environment.NewLine)
            'Check the IsReady property to see if a drive is ready
            If Info.IsReady = True Then
                Builder.Append("  Drive format " & Info.DriveFormat & Environment.NewLine)
            End If
        Next
        Array.Clear(Drives, 0, Drives.Length)

        MessageBox.Show(Builder.ToString)

Leave a Reply