Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Recursive Remove Directory
Message
De
10/12/1999 20:34:01
 
 
À
10/12/1999 17:28:36
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00302015
Message ID:
00302121
Vues:
31
Ed, you're on the right track, but not quite! The DeleteFolder method of the Scripting.FileSystemObject deletes the folder in any case, whether there are files/subfolders in it or not. So, no need for recursion.

Aren't these Scripting objects wonderful? :)

And to answer a different question in this thread: The DeleteFolder acts as the DELTREE DOS command. Since it's a COM method, it's even better than an API function.

Vlad

>You might try the following; it uses the Scripting.FileSystemObject to do the same thing, without some of the strange things related to ADIR():
>
>
FUNCTION DelFolderTree
>LPARAMETER cPathToDelete, toFSO
>LOCAL oFSO, oFolder
>IF TYPE('toFSO') # 'O' OR ISNULL(toFSO)
>   oFSO = CREATEOBJ('Scripting.FileSystemObject')
>ELSE
>   oFSO = toFSO
>ENDIF
>oFolder = oFSO.GetFolder(cPathToDelete)
>FOR EACH Folder in oFolder.SubFolders
>    DelFolderTree(Folder.Path, oFSO)
>ENDFOR
>oFolder = ''
>oFSO.DeleteFolder(cPathToDelete,.t.)
>oFSO = ''
>RETURN
>
>>I read in the help that functions' parameters are passed by value, and i THOUGHT this would protect the scoping necessary for recursion. It's late on a friday, and while i can see this isn't working, i can't seem to figure out why.
>>
>>I'm hoping someone will immediately see what i'm doing wrong. TIA
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform