Reputation: 2308
I am tring to copy a file in the current folder of the executable to a networkshare.
I used the following code, but if the file exists, it won't replace it. It be nice for it to ask if the user want to replace or not.
Set oFSO = CreateObject("Scripting.FileSystemObject")
oFSO.GetFile("c:\file.txt").Copy "\\server\sharename\", True
Upvotes: 0
Views: 4988
Reputation: 9492
Your code sample works for me for copying files. Your network share may be denying access.
FYI, there is an alternative - use FileCopy like this:
FileCopy <source file>, <destination file>
It will overwrite the destination without prompting. If you want to prompt, I can think of two ways:
Upvotes: 2
Reputation: 9994
You'll have to build your own logic for checking that the file exists and raise the message box manually based on that. You can use the FileExists function to check if the file exists.
Upvotes: 2