LabWindows/CVI

Content Type
Programming Language
Current manual

CopyFile

CopyFile

int CopyFile (char sourceFileName[], char targetFileName[]);

Purpose

Copies the contents of an existing file or group of files to another file or group of files.

If the target file is a directory, CopyFile copies the existing file or group of files into the directory.

Caution  The Windows SDK also contains a function with the same name. Include windows.h before including utility.h to ensure that there are no compilation errors as a result of this naming conflict. Define the SDK_CONFLICT_PRIORITYSDK_CONFLICT_PRIORITY macro to force LabWindows/CVI to use the Windows SDK implementation of this function.

Parameters

Input
Name Type Description
sourceFileName char [] The pathname of the existing file to copy.

sourceFileName can contain wildcard characters ? and *, in which case CopyFile copies all matching files. If you specify an empty string "", CopyFile copies the file found by the most recent call to GetFirstFile or GetNextFile.

Note    The pattern matching behavior of * is greedy and matches all subsequent characters in the pattern except the file extension. The * wildcard is useful only at the end of a filename or file extension; for example, foo*.doc*. If you use this wildcard in other locations, it matches the rest of the string; for example, *foo.txt matches bar.txt.
targetFileName char [] The pathname of the target file.

targetFileName can contain wildcard characters ? and *, in which case CopyFile matches this parameter to sourceFileName. If the target file is a directory, CopyFile copies the existing file or group of files into the directory.

Note    The pattern matching behavior of * is greedy and matches all subsequent characters in pattern except the file extension. The * wildcard is useful only at the end of a filename or file extension; for example, foo*.doc*. If you use this wildcard in other locations, it matches the rest of the string; for example, *foo.txt matches bar.txt.

Return Value

Name Type Description
result int The result of the call.

Code Description
0 Success.
-1 File not found or directory in path not found.
-3 General I/O error occurred.
-4 Insufficient memory to complete operation.
-5 Invalid path for either of the file names, or source and target file names refer to the same file.
-6 Access denied.
-7 Specified path is a directory, not a file.
-8 Disk is full.

Additional Information

Library: Utility Library

Include file: utility.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later

Was this information helpful?