Writing to an external disk - Mac

Using OS 14.5, Xojo 2024 r1.1.

In my program I was always able to write to an external drive by giving the program the full pathname, such as “/volumes/OWC Envoy Pro FX 1/Checkbook Backup/” + fldrPathSuffix, where

fldrPathSuffix = "Current Checkbook Backup/DataBud " + timeStamp
(TimeStamp) is a variable I create in the program to identify the backup.

I upgraded to an M2 Mac Studio from an i-7 iMac. Now I find that while I can still write to iCloud and OneDrive, I can no longer write to the external drive.

I’m not sure if the switch from Intel to M-2 had anything to do with that, only that I no longer know how to put a file (or folder) on an external drive.

I have both read and write permissions on the external drive, and frankly don’t understand how to get the folder “Data Bud” with its appended time stamp written to an external disk. My existing code is:

source = “/users/bart/Library/Mobile Documents/com~apple~CloudDocs/Budget! 2024/Data Bud”

fldrPathSuffix = "Current Checkbook Backup/DataBud " + timeStamp
dest = “/volumes/OWC Envoy Pro FX 1/Checkbook Backup/” + fldrPathSuffix

var ffldr as FolderItem '… The “FROM” folder
var tfldr as FolderItem '… The “TO” folder

ffldr = new FolderItem(Source,FolderItem.PathModes.Native, false) '… Create a variable in the program for the Source Folder

tfldr = new FolderItem(Destination,FolderItem.PathModes.Native, false) '…Create a variable in the program for the Destination Folder

ffldr.CopyTo(tfldr)

This works if the “TO” folder is, for example OneDrive, but I think that’s because OneDrive is merely a file on my internal SSD and the Microsoft software takes care of moving it to the cloud. Same with iCloud.

But for the life of me I don’t understand (1) why it worked before and not now; and (2) what code to change to be able to copy a folder to an external SSD.

If that code is an exact copy and paste, it won’t work. The variable Destination used to create the FolderItem isn’t defined - you call it “dest” earlier in the code.

Does your app have rights to “removeable volumes” under Settings-> Security → Files and Folder?

Yes, Marius, it does.

Eric - the variable ‘dest’ was not what is in my program. It should have read ‘destination’. My mistake. I declared “destination” as a string elsewhere. My code above was typed and I screwed up. Sorry.

I went back and assured myself that I had not made the mistake you mentioned; but in the meantime I found a spelling error in one of my variables for the pathname.

You nailed it, Eric - it wasn’t the exact item you mentioned, but your hunch was nevertheless correct. I had a spelling error in a variable that escaped me for several days of trying.

With egg on face, I thank you for making me go over the code one more time to check spelling. How I missed it is a mystery, but it is now fixed. Another “win” for the forum!

1 Like