Re: permission denied when moving folder



i am using the following to delete file,

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile "C:\data\*.*" , "\\server2\backup"

so how can I check for file existence with the line recommend by you.


"Paul Randall" <paulr901@xxxxxxxxxxxx> wrote in message news:%23JLazlzZIHA.4028@xxxxxxxxxxxxxxxxxxxxxxx

"Lee Kok Onn" <kolee@xxxxxxxxxxxxxxxx> wrote in message news:O1UEvPxZIHA.4028@xxxxxxxxxxxxxxxxxxxxxxx
Thanks for the info.

I try to use movefile in the script and I need to overwrite the same file everyday. But it prompt an error "file already exist". So its there anyway that I can overwrite the file using movefile.

Why not, just before the move, check for the existence of the file at the destination, and deleting it if necessary?

Something like:
If objFSO.FileExists(sDestinationPath) Then
objFSO.DeleteFile ( sDestinationPath[, force] )
End If

-Paul Randall


.


Loading