Is this expected to move the whole folder (subfolders and files) to the destination? I would like it to, but it didn’t seem to work that way. It only copied the sourceFolder to the destination and left the original with subfolders and files at the source location.
No comments? OK, I guess I will do the directory crawl and move thing. If anyone has any time saving ideas that leverage .MoveFileTo, please let me know.
First thing I will do is see if .CopyFileTo copies the whole directory structure, to make that part easier than copying each file and sub-directory one-by-one.
Offhand, I’m not sure about the Classic FolderItem.MoveTo, but the new framework Xojo.IO.FolderItem.MoveTo should be able to move the entire folder.
[quote=227167:@Mark Pastor]No comments? OK, I guess I will do the directory crawl and move thing. If anyone has any time saving ideas that leverage .MoveFileTo, please let me know.
First thing I will do is see if .CopyFileTo copies the whole directory structure, to make that part easier than copying each file and sub-directory one-by-one.[/quote]
On Windows CopyFile and MoveFileTo copy only separate files. See http://documentation.xojo.com/index.php/FolderItem.CopyFileTo where an example shows how to copy a folder recursively.
Both are good answers.
A third option is to invoke the shell to move or copy the folder.
I need education on this one - what does that look like?
depends on which OS you’re using
On OS X and Linux - mv, move, or cp to copy (although I prefer ditto on OS X)
On Windows MOVE or COPY to copy files
According to the classic documentation for FolderItem.CopyFileTo:
If Destination is a folder, then the folder and its contents are copied into Destination.
If Destination is a file and the file already exists, the copy is aborted. You need to delete the existing file first. If there is an error, the LastErrorCode property contains an error code.
If Windows behaves differently than OS X, then there needs to be a really huge note in the documentation about this.
Windows indeed does not copy folders. If Paul does not see this post, a documentation bug report is in order.
I implemented this approach on Windows, and it does not move the folder successfully. I believe this is your point Michel - is that correct?
I did not try the new framework move, but I am positive classic framework MoveFileTo is conformant to it’s name, it does move only files.
The confusion may come from the fact that on Mac, the same command moves the entire folder.
I don’t know about using shell, but the copy method in the LR seems fairly easy to modify with MoveFileTo instead of CopyFileTo.
Yep. Implementing that now (but using xojo.io - I like using the new framework).
If only the new framework’s LR had as many examples as the classic one… Paul is not finished yet…
What better way to learn than to struggle through it for a while :-).