Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reading directories recursively
Message
 
To
19/07/2002 08:10:03
John Faithfull
Hunterian Museum, University of Glasgow,
Glasgow, United Kingdom
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00680366
Message ID:
00680394
Views:
17
>I need to copy a directory and all its contents (files + any number of levels of subdirectories).
>
>This seems to be very difficult in VFP. I can use run xcopy, but this opens a Command Prompt window, and looks clunky.
>
>Is there a simple and elegant way to do this? If I could easily read do something like DOS:
>
>dir /s
>
>into an array, it would then be easy to step through the array, and use copy file. I can't quite see how to do this though...
>
>Any suggestions gratefully received...
>
>Thanks
>
John,

In addition to Sergey's response, you might want to consider either the Shell.Application object or the Scripting.FileSystem object.

For example, using the Shell.Application
oShell = CREATEOBJECT("Shell.Application")
* Get the target directory
oFolder = oShell.NameSpace("C:\MyFolder")
* Copy with simple progress bar and no confirmation
* on overwrite
oFolder.CopyHere("D:\MyFolder, 0x310)
Now using the Scripting.FileSystem object
oFSO = CREATEOBJECT("Scripting.FileSystemObject")
* Copy with overwrite. No progress bar
oFSO.CopyFolder("C:\MyFolder, "D:\MyFolder", .T.)
I wrote about both for the VFUG newletter (the latter with Ed Rauh). These are available on-line at www.vfug.org. Click on my name and you can find the exact issues. The Scripting.FileSystem object was the third of a series of five articles on the Windows Script Host.
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform