>We had run into similar sort of problems -- typically when printing. So what we did was to save the current directory, print, then reset the current directory:
>
>lcOrgDir = SYS(5)+SYS(2003)
>
>REPORT ....
>
>SET DEFAULT TO (m.lcOrgDir)
>
>
>You may also find that some system dialogs that do equivalent of GETFILE(), PUTFILE(), GETDIR(), FINDFILE() will sometimes change the current directory -- in those cases you can do a similar bit of saving the current directory before the operation, then restoring it. Another approach is to simply have a global setting for "current directory" for your application -- then restore the current directory as required (often in cases where certain system dialogs that change current directory gets changed, or in cases where an external program might change the current directory).
Since hunting down these things is near impossible, i.e. there are so many things which may change the default directory at unpredictable times, I've added a check to the application's maintenance timer. On launch, it saves the current location in a property, and then the timer code just checks if it's still on that location, and changes back if not. This also means that nowhere in the code it is assumed that it should run anywhere else. Any file operations are always done with full paths.