Copy Method |
Description
Copies a specified file from one location to another.
PowerBASIC Syntax
Arguments
Remarks
The results of the Copy method on a File are identical to operations performed using FileSystemObject.CopyFile where the file referred to by object is passed as an argument. You should note, however, that the alternative methods are capable of copying multiple files.
Example [PowerBASIC]
#INCLUDE "windows.inc" #INCLUDE "scrrun.inc"
DIM fso AS IFileSystem DIM pFile AS IFile
' Create an instance of the FileSystemObject fso = NEWCOM "Scripting.FileSystemObject" ' Get a reference to the IFile interface pFile = fso.GetFile(UCODE$("C:\MyFolder\MyFile.txt")) ' Copy the file pFile.Copy UCODE$("C:\MyFolder\MyFile2.txt"), %FALSE IF OBJRESULT = %S_OK THEN MSGBOX "File copied" ELSE MSGBOX "Error &H" & HEX$(OBJRESULT) & " copying the file" END IF
|