I use UiPath Studio activity ‘MoveFolderX’ to move folders within OneDrive.
It used to work very well for about 2 years, up until recently, as it began to issue such an error:
Failed to move folder. Exception:\r\nMove folder exception\r\nAccess to the path ‘(my path)’ is denied.
The worse thing is that now it moves only part of the folder, and leaves partial copies (complimentary) in the source and the destination…
Could you please check if full control (read/write permissions) is still there on the folder and the files you are trying to move.
1 quick way would be to manually move the folder and see if you are able to do so?
also check if path has changed recently? for us, we recently observed on our new win 11 machines setup, default onedrive folder name was different from our other older win 10 machines. But that may not be your scenario, just sharing that as an example to help you narrow down the issue.
That’s why I said to check for files as well, may be some of the files can’t be moved from that folder. Also, by any chance, any of the files in the folder are being used by any other application?
Are you able to move the full folder manually? if yes, then may be some glitch in automation.
Some files also could be read/write protected. Try putting a sample file to test if your code is able to move it or not. This will help you to finalize where is the issue. is it at code or at file access control.
did you try the same folder manually that’s failing using UiPath? Or a different one?
the files that didn’t move from the folder, can you try moving those files manually?
by any chance, any of the files that didn’t move were in use/locked when move was being attempted?
any of these pending files have file paths exceeding 260 characters?
any of these files were hidden or are these system files?
If you are unsure of answers to these questions,
You can try below solution instead of using move folderx activity. This would help you gain good view in which file did the move failed. Also you can skip that file and attempt moving rest of the files.
use
Directory.GetFiles(source folder here, “*”, SearchOption.AllDirectories)
and manually move files via a loop.
inside loop, surround the move file part by try catch. Catch the error thrown while moving a file , log it and move to next file.
This way you will know in the end which files were problematic and the reason of failure for individual files. Then you can handle those file errors.