Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CopyFile - File Not Found

Status
Not open for further replies.

WalleyeGuy

Technical User
Oct 18, 2007
44
US
Hiya All,

I have a script that works perfectly on XP
Well, I need to get it to work on Vista too

Basically, it copies the contents of one folder to another
Sounds simple enough; but......

Code:
Option Explicit

Const OverWriteFiles = True
Dim oFSO,objWMI,strUserName,wshNetwork,wshShell
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set wshShell = CreateObject("Wscript.Shell")

Source = "C:\Folder1"
Destintation = "C:\Folder2"

Dim oFolder,oFile,cFiles
Set oFolder = oFSO.GetFolder(Source)
Set cFiles = oFolder.Files
For Each oFile in cFiles
  oFSO.CopyFile Source, Destination, OverWriteFiles
Next

All I get is a vb runtime - file not found error
If I replace the oFSO.CopyFile... line with a WScript.Echo line it echos that line the same number of times as files are in the folder. If I suppress errors, it does not copy the files.

Any ideas?
 
oFSO.CopyFile Source & "\" & oFile.Name, Destination & "\", OverWriteFiles

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top