Is there a way to retrieve the volume names (drive labels) on a Windows system?
Specifically, I want to discover if a specific USB stick is present by scanning for its name. I already know (through the forum) how to get a list of the drive letters available (C:\, D:\ etc) but I cannot find anything on volume names.
I think that it can be done using this java method ...
Sub FindUserDocumentsFolder As String If DetectOS = "windows" Then Dim jo As JavaObject Dim fs As JavaObject = jo.InitializeStatic("javax.swing.filechooser.FileSystemView").RunMethod("getFileSystemView", Null) Return fs.RunMethodJO("getDefaultDirectory"...
www.b4x.com
Add a call to get the SystemDisplayName
B4X:
Sub FindDisplayName(f As String) As String
If DetectOS = "windows" Then
Dim jo As JavaObject
Dim fs As JavaObject = jo.InitializeStatic("javax.swing.filechooser.FileSystemView").RunMethod("getFileSystemView", Null) ' known
Dim fsfile As JavaObject = fs.RunMethod("createFileObject", Array(f)) ' new
Return fs.RunMethod("getSystemDisplayName", Array(fsfile)) ' new
Else
Return ""
End If
End Sub