CopyTo

I’m sorry to say that it works correctly using Xojo 2024r2 (I will update today) and macOS 14.6

The only problem I have is what I wrote in another thread, if instead of using the suggested name ‘MyFile.sqlite’ I display the folder files and single click one, the file is saved without extension and no file removed (because is trying to delete a file without extension that it doesn’t exist).

Yes, this is with a different computer than yesterday (home vs office).

@Enric_Herrera I’m sorry if you already posted this information but what OS version are you using?

Sonoma 14.5

I tested with macOS 13.6.8 and 14.6, sorry I don’t have 14.5 to test, it will be strange that is the problem but your last demo is working here. Sorry.

The SQLiteLoadSave.xojo.binary works on your system?

Something to keep in mind on macOS…

If the folder that you’re working in is part of the user’s iCloud account and iCloud syncing is turned on, you could be running into a locking issue. What I mean is that removing a file doesn’t mean that it’s actually gone away immediately even though it visually disappears in Finder, and the location may be “locked” for a short period while the process finishes.

This is the same reason it’s so bad to save Xojo projects into Dropbox folders. The wonky locking almost always bites you when you least expect it.

2 Likes

Yes, it works. That’s the one I tested.

Edit: I don’t use iCloud or other sync. (After I read Greg’s comment)

No, not saving to iCloud, using the desktop.

Or I’m doing something wrong or …

Unless you’ve turned it off, Desktop is part of iCloud.

Try working in a folder where the name has .nosync as an extension.

[Dropbox]

This shoud be a link to a video… no other way to post…

RESUME

I very much believe that, or it’s me (wrong code), or is Xojo, but not MacOS or iCloud

On old projects, when user decide to save with the same name, that worked using:

if dbFile <> nil then
  db.DatabaseFile.CopyFileTo(dbFile)
end if

FolderItem.CopyFileTo was deprecated in version 2019r2.1

Now using FolderItem.CopyTo

if user decide to save with the same name, and I did not remove the old file an IOException happens. if I remove the old file then nothing is saved.

if dbFile <> nil then
  if dbFile.Exists then dbFile.Remove
  db.DatabaseFile.CopyTo(dbFile)
end if

More info, the Xojo example Files/copy and move (and official example from Xojo)

If you execute the Create copy, delete twice the second one crashes IOException , because the file created at the desktop already exists (Copy and Move Text File1.txt).
Same happens with the Create and move button code.