Renaming a volume

Back in the glory days of API1 and Xojo 2019r1.1, I could programmatically rename a volume by assigning a new name to it, e.g.

Volume(i).Name = "Garbage"

With API2 and Xojo 2020r2.1, I can’t seem to do that:

DriveAt(i).Name = "Garbage"

does nothing, and doesn’t throw an exception.

Any ideas? Or should I brave trying to find an MBS solution?

The help info for FolderItem.Name is a bit confusing:

The name of the FolderItem. Changing this name will change the name of the file or folder.


It will rename files if the user has permission to rename them, they are not in use, and it is not a folder or temporary file. The file must exist in order to be assigned a name.

Renaming fails if another file with same name exists already. In that case, delete the existing file before renaming.

If renaming the file fails for any reason, an IOException will occur.

This seems to infer that it can and cannot change the name of a folder. Go figure. It also states that an IOException will occur if the renaming fails. It doesn’t.

You can try

setResourceValue(value as Variant, key as string, byref error as NSErrorMBS) as boolean

in NSURLMBS class with NSURLVolumeNameKey as key and see whether it works.

Perfect. Thanks.

it would be nice to have a solution without a plugin.
may be you should fill a bug case ?

I can do that. Also, a cross-platform solution would be nice. It’s more of a bug since it’s a regression from 2019r1.1 and API1.

IIRC they changed the Mac API’s they used under the hood for files fairly recently… If that is the case, was it after 2019 r1.1?

BTW if you use API 1 code in the current version, does that work? If it was an unwed teh hood API crag would expect that to a fact API 1 code as well as in most coast I think the API calls they use are likely the same…

So if the API 1 code works in the current version, it would alley be an API 2 implementation bug, if not it’s likely due to a Mac API change.


It worked in 2019r1.1 using API 1. It doesn’t work in 2020r2 using either API 1 or API 2. I haven’t used any of the interim versions. You are probably correct that it’s a change with the internal OS APIs being used. I’m busy putting a demo app project together, since that seems to be the trick to get stuff verified.

One of things I noticed is that newer Mac OS API tend to be less “Mac” like and more Windows like… The not being able to rename something in use is a very Windows like behavior, that as a long time Mac user, has always annoyed me.

Oh well I guess the kids working at Apple grew up using PC’s! :wink:


You certainly have an unusual task that needs to rename a volume name.

I set volume name at format time (only).

I distribute some software on flash drives. It involves copying and verifying files and renaming the flash drive volume appropriately. This is all done via a Xojo program. I could do the renaming manually, but knowing me, I will forget.

OK, thank you.