After MoveTo what is the FolderItem

Mac Mojave/Xojo 2012 r1.2
I have a Folder Item (PNG file in this case) that I want to move to a different folder and then open it. But if I move it and then issue the command to open, nothing happens. If I do not move it first, then it opens just fine.

So it seems that if you move a file, using the command MoveTo then your folder item ceases to exist.

selectedFolderItemPNG.NativePath is not changed to reflect its new location. And if you test it, selectedFolderItemPNG no longer exists.

This seems peculiar to me and I do not think that the Documentation is clear in this regard.
What is the best way to get a FolderItem pointer to the file that you have just moved?

Var selectedFolderItemPNG As FolderItem

// move it to different folder
Const FOLDER_JPEG As String = "ScreenShotJPEG"
Var destinationFolder As FolderItem

destinationFolder = SpecialFolder.Desktop.Child(Self.GRANDPARENT_FOLDER).Child(FOLDER_JPEG)

selectedFolderItemPNG.Open // This will fail to do anything

Dead, is what it is. The below should help. Instead of just moving the file into the folder, create a specific reference for the moved file.

dim destinationFile as folderitem = destinationFolder.trueChild( )
selectedFolderItemPNG.moveTo destinationFile

An alternative is a referenceFolderitem object that I’ve been working on, which knows where files have been moved too.


dim destinationFile as folderitem = destinationFolder.trueChild( )selectedFolderItemPNG.moveTo destinationFile

Well that nudges me in a direction that works for me

Var selectedAfterMove As FolderItem
selectedAfterMove = destinationFolder.Child(

Var selectedAfterMove As FolderItem
selectedAfterMove = destinationFolder.Child(

The above works for me. Thanks.

trueChild?? is a little confusing. In my hands, just Child works fine.

I guess that TrueChild is a now deprecated way of just saying Child.

trueChild ensures that you get the file at that location with zero alias/symlink/bookmark resolution. Sounds like it may have gotten changed with API 2.0.

If you attempt to get the new file after it was moved, you’re guaranteed that you get the correct file (except if MoveTo encountered an error, but that’s in all cases).

I usually do it like this:

dim File,Destination as folderitem

//(here, define File as the file to move); then…


File.MoveTo Destination
File=Destination.child( // is still valid here; get the new moved file.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.