Finding a Volume on Windows?

Greetings -

Xojo 2019 R3.1

I need, at various points in my program, to detect whether or not a particular SD card has been inserted in a reader or return a FolderItem for that SD card. It will always have a volume name of “STRONTIUM”. On MacOS, it is easy, because FolderItem.Drive.DriveAt(i) returns useful names like “Mac HD” or “MyUSBStick” or “STRONTIUM”. But, on Windows, it only returns names like “C:” or “D:”. The drive name changes on Windows (at various times), according to what else is mounted.

Further, none of the properties of the FolderItem returned by DriveAt() seems to contain that name “STRONTIUM” (or, any other distinguishing information) though WindowsExplorer certainly knows. I can search through the children of a FolderItem to test for the presence of known files, but that can be a slow process on a big USB drive. I guess that I could abandon the search if nothing is found within a dozen or so tries, but that seems to be a bit of a hack.

Can anyone suggest how to improve this process?

Many thanks
Jim Wagner
Oregon Research Electronics

Have a read through https://forum.xojo.com/t/how-can-i-access-a-volume-by-name/21542 there’s plenty of code snippets and pointers there, let us know if you get stuck on any finer points. The code I posted on dropbox will do what you want but might be a little overkill and or need some work but there are nuggets of info on that thread including links to the WFS in Andrew post.

Thanks, Julian -

Though I have used RB/Xojo since version 0.9, I have never seen anything like the code in WFS and I am having some problems with the soft declared functions in the GetVolumeName. In particular, the root.absolutepath appears to not exist anymore and I don’t know whether to replace it with root.nativepath or root.shellpath. Nativepath has a note in the LR about a distinguishing feature between it and absolutepath, It is not clear what changes might be needed to use nativepath.

Your advice is appreciated!

EDIT: Replacing absolutepath with native path appears to work, though it leaves me with more than a little feeling of dread, not knowing whether or not there might be a hidden minefield that just got installed there. It DOES NOT work with the one USB thumb drive I tried; it just returned the drive letter D: /EDIT

Jim

As far as I’m aware, AbsolutePath and NativePath were/are the same under Windows so changing to NativePath should be fine.

Does this help you at all?

If it doesn’t help, can you paste in your output from the debug window run of the above and a simple sample project that you’re trying?