>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
Why do you do it one by one and not by the whole folder with subfolders?
oFSO.CopyFolder(< source folder >, < target folder >, [ overwrite ])
If it's not broken, fix it until it is.
My Blog