[SOLVED] Problem with moveFileTo on PC (but not Mac)

I’m trying to rename a folder using File::moveFileTo(), but it’s failing on the PC. It works fine on the Mac.

The folder and the file(s) inside of it were all created by my VST3 plugin, and checking the Properties I can see that everyone (Current user, Admins, etc.) have Full Control permissions. But still it fails to rename the folder, returning false (from the Windows call to MoveFile() inside File::moveInternal()).

Here is a screen capture of the File object on which I am calling moveFileTo, taken while stopped inside File::moveInternal(), which shows both the current file path and the destination file path. I don’t see what the problem might be. Any ideas?

If I delete the file(s) inside that folder just before calling moveFileTo(), then it works! The Windows docs say that it works with directories that include files, and my plugin created the file(s) in the first place, and Full Control is shown for the permissions for both the folder and its file(s), so what could be the problem? The File::moveInternal doesn’t call GetLastError(), so I have no access to why the rename failed.

(I am running Windows 10, by the way.)

I have no idea what to do now. I don’t want to copy the files and then delete the original, because they might be fairly large (.wav files). Any ideas?

Never mind, I found it! I had a reader and input file stream attached to the file inside that folder, and on Windows that prevented the parent folder from being renamed. So I cleared those and now it works as desired. Whew! :slight_smile:

1 Like