Question
· Nov 17, 2016

%file RemoveDirectory

Hi

I'm trying to use the ##class(%File).RemoveDirectory utility to delete a windows folder. The folder has nothing in it, but it is not getting deleted.

I've tried doing Set sc=##class(%File).RemoveDirectory(file,.return) and return is returning a -2.  I've also tried changing it to .Delete in case that worked, but I got the same. 

I've tried it on my local instance and on a customer site on an older version of Cache that doesn't have the return parameter, but it also fails to delete the folder on there too.

file is the full filename and path and the .Delete works fine when used on files.

Any ideas why it's failing or what the -2 means?

thanks

Discussion (3)0
Log in or sign up to continue

I think these error codes correspond to Windows system error codes - see this page.

So -2 corresponds to "ERROR_FILE_NOT_FOUND" and -3 to "ERROR_PATH_NOT_FOUND"

It seems more likely that you would get -2 from ##class(%File).Delete(file,.return). passing a directory that simply doesn't exist to RemoveDirectory results in -3. Is RemoveDirectory actually returning that error code, or perhaps a different one?

Wendy,

   Is the file on a mapped device?  If so does the session that is issuing the '.RemoveFile()' see the mapping.  You can check this by having the session issue a command like 's X=$ZF(-1,"NET USE > C:\Temp\UseResult-"_$J_".txt")'.  Note that "Cache Terminal ($I="|TRM|*") get the logged in users mapping while JOBbed processes, those coming in via telnet, or other TCP/IP based connections get the mappings of the Cache service.  For example, from Cache Terminal ($I="|TRM|:|13248") I get:

New connections will be remembered.


Status       Local     Remote                    Network

-------------------------------------------------------------------------------
Unavailable  H:        \\cambnfs1\nethome\clarkm Microsoft Windows Network
OK           L:        \\192.168.10.32\Library   Microsoft Windows Network
OK           S:        \\192.168.10.32\Scratch   Microsoft Windows Network
OK           W:        \\supnfs1\supscratch1\clarkm
                                                Microsoft Windows Network
OK           X:        \\refiles\scratch1\clarkm Microsoft Windows Network
Unavailable  Y:        \\refiles\scratch2\clarkm Microsoft Windows Network
Unavailable  Z:        \\refiles\scratch3\clarkm Microsoft Windows Network
Unavailable  LPT2:     \\192.168.10.36\Canon MP530 Series Printer
                                                Microsoft Windows Network
The command completed successfully.

   However from a Telnet session ($I="|TNT|CMATTHEWS6440.iscinternal.com:11992|12936") I see:

New connections will be remembered.

There are no entries in the list.

   This is because the telnet session does not see the mappings that the logged in user has.  If you want the service to, you will need to add the mappings somewhere using a NET USE command.  In Cache you can put it in the %ZSTART routine, or you can put it in your application code.