devxlogo

GetDriveLabel – Retrieving the label of the specified drive

GetDriveLabel – Retrieving the label of the specified drive

' Retrieve the drive name (label) of the specified drive' Note: requires a reference to the System.Management assembly' Example: MessageBox.Show(GetDriveLabel("D"c))Function GetDriveLabel(ByVal driveLetter As Char) As String    Dim driveFilter As String = "Win32_LogicalDisk=""" & driveLetter.ToString & _        ":"""    Dim drive As New System.Management.ManagementObject(driveFilter)    Return drive("VolumeName")End Function

devx-admin

Share the Post: