Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DELETE FILE with WildCards
Message
From
05/11/1998 13:30:02
 
 
To
05/11/1998 13:11:51
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00154920
Message ID:
00154939
Views:
15
>Vfp 5.0a SP3
>
>In HELP for DELETE FILE, it says under Remarks:
>
>"The file you want to delete cannot be open when DELETE FILE is issued. The file name must include a path if it is on a different drive or volume, or in a different directory or folder from the default, and the file name extension must be included. The file name cannot contain wildcards."
>
>… but when my default is on drive C: and I issue the command "DELETE FILE D:\Temp\xxx*.*", all files in D:\Temp matching xxx*.* ARE successfully deleted. As it turns out, this is what I want to happen. I do have concerns, though, as the documentation seems to say that this capability is not supported.
>
>How safe am I to rely on this capability?
>

It seems to work in most cases; I don't rely on the capability myself, instead, I use ADIR() to populate a list of files to delete, and then ERASE them one at a time. I've seen inconsistent results with wildcarded file deletion (which inevitably fails when I plan on doing something like an RMDIR once I've "emptied" the directory) and have gotten back in the habit of not relying on wildcarded deletion. Another advantage to spinng through the files one at a time is that I can remove Hidden/System/read-Only flags from the files by calling a Win32 API function before deleting the file,as in the following example:
DECLARE INTEGER SetFileAttributes IN Kernel32 ;
	STRING cFileNameToAlter, ;
	INTEGER nAttributeMask
DECLARE aFiles[1,5]
nNumFiles=ADIR(aFiles,'D:\MyDir\*.*','SH')  && include system/hidden files
FOR i = 1 TO nNumFiles
   =SetFileAttributes('D:\MyDir\'+aFiles[i,1],0)
   ERASE ('D:\MyDir\+aFiles[i,1])
ENDFOR
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform