Fabio Care · May 25

%File Delete not Working

Hey there,

I'm writing an import Routine to read files into a global. The code is working fine except for the 'Delete' command. The files are being imported, copied but not deleted. Maybe someone has an Idea what ist happening.

I get the low level return value of -32 but i couldn't find anywhere to show me what that actually means. And my Caché version doesn't support the $ZU command.

Here's the Code

 SET PATH="C:\inetpub\ftproot\File_Import\"
 SET ARCHIVPATH="C:\inetpub\ftproot\File_Import\Imported\"
 SET FAILPATH="C:\inetpub\ftproot\File_Import\Failed\"
   .SET STREAM=##class(%Stream.FileCharacter).%New()
   .DO STREAM.Rewind()
   .SET DATA=""
   .SET LINE=STREAM.ReadLine()
   .IF ($L(DATA)+$L(LINE))>3600000 SET LIMIT=-1
   .IF LIMIT=-1 Q
       .SET DATA=DATA_LINE_$C(13)_$C(10)
    .IF LIMIT'=-1 DO ##class(%File).CopyFile(FILE,ARCHIVPATH)
    .IF LIMIT=-1 DO ##class(%File).CopyFile(FILE,FAILPATH)
    .do ##class(%File).Delete(FILE, .RETURN)

 Output for a single file is: 


Thank you for any advice.

Product version: Caché 2017.1
$ZV: Cache for Windows (x86-64) 2017.2 (Build 744U) Fri Sep 29 2017 10:58:27 EDT
0 172
Discussion (7)1
Log in or sign up to continue
.SET SC=STREAM.LinkToFile(FILE)   // A
.do ##class(%File).Delete(FILE, .RETURN)  // B

As long you hold your hand on a file (line A), you can't delete the file (line B). You have to do something like

 set SC = "" // or
 kill SC

Bye the way, non of Cache/IRIS has an $ZU command but all versions have a bunch of $ZU() functions. So what do you want to do with them?

I read some random post in the community that said you could evaluate the low level return with the $ZU() command. But maybe that was something different

Neither of those command worked, that was what I thoguht at first too. But killing the STREAM did the trick, so you pointed me in the right direction. Thanks. 

Check acces rights to the files.
Especially for the Windows USER your Caché installation is runing on. 

Windows error codes are here.


32 (0x20)

The process cannot access the file because it is being used by another process.