Click or drag to resize

FCopy Function (String, String)

X#
Copy a file to a new file or to a device.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.21
Syntax
 FUNCTION FCopy(
	cSourceFile AS STRING,
	cTargetFile AS STRING
) AS LOGIC
Request Example View Source

Parameters

cSourceFile
Type: String
The name of the source file to copy, including an optional drive, directory, and extension.
If cSourceFile does not exist, a runtime error is raised.
If it exists, this function 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.
cTargetFile
Type: String
The name of the target file, including an optional drive, directory, and extension.
If cTargetFile does not exist, it is created.
If it exists, this function 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 function does not supply a default extension for either file name.
cTargetFile can also be 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, FCopy() searches the Windows registry for a Device entry to use for the printing device.
If there is no Device entry, it looks for the Devices entries and presents the user with a list box of devices from which to choose.

Return Value

Type: Logic
TRUE if successful; otherwise, FALSE.
Remarks
FCopy() is the functional form of the COPY FILE command.
Examples
This example copies a file from the default drive and directory into MYDIR directory on the D drive:
X#
1? FCopy("thisfile.txt",; "d:\mydir\thisfile.txt")
See Also