Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Remove root folder with files and subfolders
Message
From
22/09/2000 08:03:46
 
 
To
22/09/2000 07:39:07
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00419622
Message ID:
00419632
Views:
44
>Hello!
>Can anybody share code for remove root folders with internal files and subfolders

The Scripting.FileSystemObject can do this directly on other than the root of a drive; look at the DeleteFolder method. It cannot delete the root folder, so you'd need to obtain the root folder object of the drive and then iterate the SubFolders collection and Files collection yourself, invoking the Delete method of the contained objects, something along the lines of:
oFSO = CREATEOBJ('Scripting.FileSystemObject')
oRoot = oFSO.GetFolder('F:\')
FOR EACH oFolder IN oRoot.SubFolders
   oFolder.Delete(.T.)
ENDFOR
FOR EACH oFile IN oRoot.Files
   oFile.Delete(.T.)
ENDFOR
This requires the WSH. You may have to change attributes of folders and files with the System attribute set before invoking their Delete methods. The deletions are not saved to the Recycle Bin, so you're screwed if you're wrong.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform