| xHarbour Reference Documentation > Command Reference |
![]() |
![]() |
![]() |
Copies a file to a new file or to an output device.
COPY FILE <cSourceFile> TO <cTargetFile>|<cDevice>
COPY FILE is a file command that copies a source file to a new file or output device. When <cSourceFile> does not include drive and directory information, the file is searched first in the current directory and then in the directory specified with SET DEFAULT. If <cSourceFile> is not found, a runtime error is generated.
When <cTargetFile> exists, it is overwritten without warning.
| See also: | COPY TO, ERASE, FErase(), File(), FRename(), RENAME, SET DEFAULT |
| Category: | File commands |
| Source: | rtl\copyfile.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// This example demonstrates various possibilities of the COPY FILE
// command
PROCEDURE Main
LOCAL cFile := "TEST.TXT"
COPY FILE (cFile) TO Tmp.txt
COPY FILE Tmp.txt TO LPT1
RETURN
http://www.xHarbour.com