Method: Copy for File
- Updated2024-09-12
- 1 minute(s) read
FileSystemObject and Dictionary > Methods > Method: Copy for File
Method: Copy for File
Copies a file to a different folder or to another file.
Object.Copy(Destination, [OverWriteFiles])
| Object | File Object with this method |
| Destination | String Specifies the path of the target folder or the target file to which DIAdem copies the source file. The path of the target folder or the target file must not contain wildcards. |
| [OverWriteFiles] | Boolean Specifies whether DIAdem overwrites existing files. If the value is True, DIAdem overwrites existing files. If the value is False, DIAdem does not overwrite existing files. The default value is True. |
![]() | Note The copy method aborts as soon as the first error occurs. DIAdem does not undo changes made to the file system before an error occurred. |
The following example copies the complete folder Example\Documents below the DIAdem program folder to the folder C:\Temp\Documents:
Sub CopyMyFiles(sSource,sTarget,bOverwrite) Dim fso, oMyFolder, oMyFiles, oMyFile Set fso = CreateObject("Scripting.FileSystemObject") set oMyFolder = fso.GetFolder(sSource) set oMyFiles = oMyFolder.Files For Each oMyFile in oMyFiles Call oMyFile.Copy(sTarget,bOverwrite) Next End Sub Call CopyMyFiles(ProgramDrv & "Examples\Documents\", "c:\Temp\Documents\",True)
