ChrisRChamberlain
Programmer
In most situations, the native DELETE FILE will delete the named file(s).
But what if the files have not been deleted and subsequent events are dependant on their removal?
You then need to verify the existence of the file(s) with either FILE(), (which will fail under certain circumstances) or ADIR().
Enter the WinAPI call DeleteFile().
Disadvantage - will not accept wildcards, but you can programatically loop through the file names.
Advantage - the return value of the function will indicate the success or otherwise of the delete.
Syntax -
DECLARE INTEGER DeleteFile IN kernel32 ;
[tab]STRING lpFileName
lcFilename = [C:\My app\test.doc]
lnRetVal = DeleteFile(lcFilename + CHR(0))
IF lnRetVal = 0
[tab]MESSAGEBOX([Error - ] ;
[tab][tab]+ lcFileName ;
[tab][tab]+ [ - has not been deleted!])
ENDI![[pc2] [pc2] [pc2]](/data/assets/smilies/pc2.gif)
But what if the files have not been deleted and subsequent events are dependant on their removal?
You then need to verify the existence of the file(s) with either FILE(), (which will fail under certain circumstances) or ADIR().
Enter the WinAPI call DeleteFile().
Disadvantage - will not accept wildcards, but you can programatically loop through the file names.
Advantage - the return value of the function will indicate the success or otherwise of the delete.
Syntax -
DECLARE INTEGER DeleteFile IN kernel32 ;
[tab]STRING lpFileName
lcFilename = [C:\My app\test.doc]
lnRetVal = DeleteFile(lcFilename + CHR(0))
IF lnRetVal = 0
[tab]MESSAGEBOX([Error - ] ;
[tab][tab]+ lcFileName ;
[tab][tab]+ [ - has not been deleted!])
ENDI
FAQ184-2483 - the answer to getting answered.
Chris ![[pc2] [pc2] [pc2]](/data/assets/smilies/pc2.gif)