Copy File API
-
@DanH Are you sure that
LicenseFile
exists? I haven't checked but it could be that the target has to be a file not a directory:LicenseFile.copy(FileSystem.getFolder(FileSystem.AppData).getChildFile("MyLicense.txt"));
-
@d-healey aha that was it, thanks!
-
-
@d-healey If you copy a file somewhere you must ensure that the parent directory exists or the copy action will fail (because it will never implicitly create directories).
-
@d-healey it needed to be written / copied to a file, not a directory :)
-
Does copy() only work for specific types of files? I'm trying to copy image files, but it's not working:
const var sourceFile = FileSystem.getFolder(FileSystem.Desktop).getChildFile("OldImage.jpg"); sourceFile.copy(FileSystem.getFolder(FileSystem.Downloads).getChildFile("NewImage.jpg"));
but it works with text:
const var sourceFile = FileSystem.getFolder(FileSystem.Desktop).getChildFile("OldText.txt"); sourceFile.copy(FileSystem.getFolder(FileSystem.Downloads).getChildFile("NewText.txt"));
If so, how can I copy images to new locations?
-
@Dan-Korneff I just tested and this works for me
const source = FileSystem.getFolder(FileSystem.UserHome).getChildFile("original.png"); const target = FileSystem.getFolder(FileSystem.Desktop).getChildFile("test.png"); source.copy(target);
-
@d-healey Thanks for testing! It looks like pilot error. It WAS copying the files... with the original attributes. When I sorted my file browser by date, I was expecting to see the new file at the top.
-
@Dan-Korneff said in Copy File API:
When I sorted my file browser by date, I was expecting to see the new file at the top.
I'm guessing you're on a Mac?
-
@d-healey PC
-
@Dan-Korneff Oooh I thought it would give fresh meta data on Windows, interesting!
-
@d-healey said in Copy File API:
@Dan-Korneff Oooh I thought it would give fresh meta data on Windows, interesting!
create dates would be the same I think - date modified should be different on Windows