Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Scripting File Copy Error
Message
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00951028
Message ID:
00951261
Views:
8
>I'm trying to copy the contents of one folder to all of the subfolders of another folder. The following code works fine if the files I am copying do not exist in the destination directory. If the files do exist then I get the error 'invalid com status code'. I thought the last parameter of the copy function would automatically overwrite the files if they exist but I guess I am wrong. Is there anyone else out there who has had the same problem? Thanks for any help.
>
>fso = CREATEOBJECT("Scripting.FileSystemObject")
>flFrom = fso.getfolder(m.FromCopy)
>flTo = fso.getfolder(m.ToCopy)
>subcount = flto.subfolders.count
>FOR EACH oFolder IN flto.subfolders
>	*WAIT WINDOW 'Copying to: ' + ALLTRIM(oFolder.path) nowait
>         flfrom.copy(oFolder.path,.T.)
>endfor
Kendall,

Check my article in the VFUG newsletter on the Shell.Application. It appeared in May of 2000 (I think). You can use the namespace's CopyHere function to do this, and, if you wish, display a progress bar at the same time. Details are covered in the article, which is available on-line at www.vfug.org.

Update - Or you can use the CopyFolder method in the FSO. The late Ed Rauh and I wrote about it in the third of the series of articles on the WSH that appeared in the VFUG newsletter beginning in September, 2000.
George

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

Click here to load this message in the networking platform