Currently, after uploading the file to an SFTP host, I move the local file to an archive directory.
Program logic:
PSUtilities.file:moveFile()— move file from
D://upload/→D://upload/backup/PSUtilities.file:renameFile()— rename the archive file from
D://upload/backup/test_file.xlsx→D://upload/backup/test_file.xlsx_20250812
Occasionally, PSUtilities.file:renameFile() fails with the following message:
PSUtilities.file:renameFile() – Move file and obtain target path
If I retry a few times, it sometimes works.
Question:
- What could cause
renameFileto fail right aftermoveFile? - Is it possible that the file is still locked by the OS after the move operation on Windows?
- Any recommended best practices to avoid this issue (e.g., delay, direct move+rename in one step, etc.)?
Thank you!