xHarbour Reference Documentation > Command Reference xHarbour Developers Network  

COPY FILE

Copies a file to a new file or to an output device.

Syntax

COPY FILE <cSourceFile> TO <cTargetFile>|<cDevice>

Arguments

<cSourceFile>
This is the name of the source file to copy. It must include path and file extension and can be specified as a literal file name or as a character expression enclosed in parentheses.
TO <cTargetFile>
This is the name of the target file to create. It must include path and file extension and can be specified as a literal file name or as a character expression enclosed in parentheses.
TO <cDevice>
This is the name of an output device, such as LPT1, for example. It can be specified as a literal device name or as a character expression enclosed in parentheses. When the device does not exist, a file with the name <cDevice> is created.

Description

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.

Info

See also:COPY TO, ERASE, FErase(), File(), FRename(), RENAME, SET DEFAULT
Category: File commands
Source:rtl\copyfile.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe