RuntimeException 102 on Xojo.IO.FolderItem.CopyTo

The following code works perfectly on macOS:

dim theme as Xojo.IO.FolderItem theme = Xojo.IO.SpecialFolder.GetResource("primary") theme.CopyTo(root.Child("themes"))

Where root is defined elsewhere as a Xojo.IO.FolderItem. Also root.Child("themes") exists before the copy is attempted and primary is a folder that is copied to the app’s Resources folder via a BuildStep on both Windows and macOS. Running this in debug mode, the debugger stops at the second line above with a RuntimeException. No message/reason is given just an error code: 102. I have tried this on three PCs (all running Windows 10) and have tried running Xojo as an administrator. This also happens using the remote debugger.

If I inspect theme and root in the debugger, then it tells me they also exist and are writable and readable.

Is this some sort of Windows 10 bug? Having no issues whatsoever on macOS.

Help please!!

102 is basically the same error as the classic folderitem (access denied)

http://documentation.xojo.com/index.php/FolderItem.LastErrorCode

Are you trying to copy a file INTO the resources of an app thats been installed (perhaps in a place like C:\Program Files) ?
Is the app open and that file is busy ?

Not sure why it’s access denied as running as admin and trying to copy to the desktop…

Running as admin should be sufficient

Antivirus blocking the copy ?

[quote=339964:@Norman Palardy]Running as admin should be sufficient

Antivirus blocking the copy ?[/quote]
Nope, no antivirus or Windows defender. I just don’t get it. I wonder if it’s something to do with the fact that theme uses the Xojo.IO.SpecialFolder.GetResource method? I know it’s not a permissions issue (even though that’s what error 102 is) because I am able to write folders and text files to the root Xojo.IO.FolderItem. It only seems to fail when copying a folder…

Nope, no antivirus or Windows defender. I just don’t get it. I wonder if it’s something to do with the fact that theme uses the Xojo.IO.SpecialFolder.GetResource method? I know it’s not a permissions issue (even though that’s what error 102 is) because I am able to write folders and text files to the root Xojo.IO.FolderItem. It only seems to fail when copying a folder…

This smells like a bug in the Xojo.IO.FolderItem class…

I’m trying to copy a folder in the App’s Resources folder (put there with a build step from the IDE) called primary to a folder called themes in a folder called root. There are a bunch of folders and files in primary. One of which is called post.html.

This fails with RuntimeException 102:

dim theme as Xojo.IO.FolderItem theme = Xojo.IO.SpecialFolder.GetResource("primary") theme.CopyTo(root.Child("themes"))

This works:

dim theme as Xojo.IO.FolderItem theme = Xojo.IO.SpecialFolder.GetResource("primary") theme = theme.Child("layouts").Child("post.html") ' this happens to be a random file (not a folder) theme.CopyTo(root.Child("themes"))

Is there a known problem trying to copy a folder into another folder using Xojo.IO.FolderItem on Windows 10 or am I doing this wrong?

permissions is the only thing I can think of

Try the “Repair Permissions” voodoo :stuck_out_tongue:

That’d be plausible on macOS but this is Windows we’re talking about (hence why this is in the Targets > Windows channel)

Would a permissions problem explain why copying a folder to a destination fails but copying a file to the same place succeeds?

I’ll try and refactor the code to use a shell and see if that solves the problem. If it does, I’ll file a bug report against Xojo.IO.FolderItem

I’m thinking its the permissions on whats being copied - since you can copy TO the destiination

Are you able to replicate this in a small sample program that you can post?

If you can, I’ll take a look at it.