Note | This command is defined in a header file and will be preprocessed by the X# preprocessor to a function call. If you disable the standard header (-nostddefs) files then this command will not be available. If you tell the compiler to use a different standard header file (-stddef ) then this command may also be not available |
Copy a file to a new file or to a device.
COPY FILE <xcSourceFile> TO <xcTargetFile> | <xcDevice>
<xcSourceFile> | The name of the source file to copy, including an optional drive, directory, and extension. |
If <xcSourceFile> does not exist, a runtime error is raised. If it exists, this command attempts to open the file in shared mode and, if successful, it proceeds. If access is denied because, for example, another process has exclusive use of the file, NetErr() is set to TRUE. |
TO <xcTargetFile> | The name of the target file, including an optional drive, directory, and extension. |
If <xcTargetFile> does not exist, it is created. If it exists, this command attempts to open the file in exclusive mode and, if successful, the file is overwritten without warning or error. If access is denied because, for example, another process is using the file, NetErr() is set to TRUE. |
See SetDefault() and SetPath() for file searching and creation rules. This command does not supply a default extension for either file name. |
TO <xcDevice> | The name of the target device specified without a trailing colon. When you specify one of the following device names: PRN, LPT1, LPT2, LPT3, COM1, or COM2, COPY FILE searches the Windows section of WIN.INI for a Device entry to use for the printing device. If there is no Device entry, it looks for a Devices entry and presents the user with a list box of devices from which to choose. |
This example copies a file to a new file, then tests for the existence of the new file:
COPY FILE test.prg TO real.prg
? File("real.prg") // Result: TRUE
The next example prints the contents of a file by copying it to the default device:
COPY FILE real.prg TO PRN
XSharp.Core.DLL
COPY TO, FCopy(),DELETE FILE, RENAME, SetDefault(), SetPath()