Monday, August 22, 2005

Getting the volume label in .Net

To get the volume label of a particular drive, use the Dir method in the VisualBasic namespace. Note that you can ONLY use the Volume fileattribute if you want to get the volume name. Use of any other attribute will prevent the volume label from being returned. On my system, the DVD drive is my E:\, so the following statement successfully returned the volume label for me:

'Get the CD/DVD volume label
Dim VolumeLabel As String = _
Microsoft.VisualBasic.Dir("E:\", FileAttribute.Volume)


Joe Kunk

1 comment:

Ali Barrak said...

this was very useful
thank you very much