Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Recursive Remove Directory
Message
De
10/12/1999 17:31:10
 
 
À
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:
00302036
Vues:
28
>>semi-follow up to the MD issue
>>
>>I need to remove a root directory, which may contain subdirectories. Recursion seemed the simplest solution:
>>1. Delete the files
>>2. Remove the subdirectories
>>3. Remove the root directory
>>
>>FUNCTION RemoveDirectory
>>Parameters dirpath
>> Dele file (dirpath+"*.*")
>> entries = adir(aRemDirs,dirpath+"*.*","D")
>> If entries >= 0
>> for i = 1 to entries
>> If !Inlist(aRemDirs(i,1),".","..")
>> RemoveDirectory(dirpath+aRemDirs(i,1)+"\")
>> Endif
>> Next
>> Endif
>> RD (dirpath)
>>Return && RemoveDirectory
>>
>
>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

Ed,

Do you know if there's any Win32API equivalent of the DOS DELTREE command?
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform