Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Deleting a Hidden File
Message
De
22/03/1999 15:27:01
Bob Lucas
The WordWare Agency
Alberta, Canada
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00200423
Message ID:
00200646
Vues:
10
>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.)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform