First of all, you're calling class methods, so you don't need a file object. Instead of:
s file=##class(%File).%New() d file.CopyFile(File,ArchivePath) d file.Delete(File)
It's enough to write:
do ##class(%File).CopyFile(File,ArchivePath) do ##class(%File).Delete(File)
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
- Log in to post comments