General information
Category:
Coding, syntax & commands
>I want to delete all files is a user chosen dir. I use ADIR() to get a file listing and the command DELETE FILE .... to delete each file using a FOR ... NEXT loop.
>But this fails when it encounters a hidden file.
You might want to try using a filesystemobject such as:
*-- filespec is the name of the file to be played with
fs = CreateObject("Scripting.FileSystemObject")
*-- f will be a file object
f = fs.GetFile(fs.GetFileName(filespec))
*-- if the file is hidden, remove the hidden attribute
*-- this may not be necessary in order to delete
If f.attributes and 2
f.attributes = f.attributes - 2
EndIf
*-- pass the force parameter to force a delete even if
*-- the file is read-only
*-- this could also be done be checking the readonly attribute (
*-- f.attributes and 1
f.delete(.t.)
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only