First of all, you're calling class methods, so you don't need a file object. Instead of:
It's enough to write:
Other things to consider:
- You have file and File variables. That makes understanding what's going on more difficult than it should be.
- Using full command names (set instead of s, do instead of d, etc.)
But, %File class has a method specifically for moving, so it's better to call it:
set Success = ##class(%File).Rename(File, ArchivePath, .RetCode)
write:(Success=$$$NO) "Rename failed with code: " _ RetCode