Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Recursive Remove Directory
Message
From
10/12/1999 20:34:01
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00302015
Message ID:
00302121
Views:
32
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform