LabWindows/CVI

Content Type
Programming Language
Current manual

RenameFile

RenameFile

int RenameFile (char existingFileName[], char newFileName[]);

Purpose

Renames an existing file or a group of existing files.

RenameFile fails if a file already exists with the new filename. If this error occurs after renaming some of the files in a group, this function returns immediately.

RenameFile can rename files across different disk drives. If you specify different disk drives in the parameters, RenameFile copies the source to the target and then deletes the source file.

(Linux) If you specify files on different file systems, RenameFile copies the source to the target and then deletes the source file.

Parameters

Input
Name Type Description
existingFileName char [] The pathname of the file to rename.

existingFileName can contain wildcard characters ? and *, in which case RenameFile renames all matching files. If you specify an empty string "", RenameFile renames 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.
newFileName char [] The pathname of the new file name.

newFileName can contain wildcard characters ? and *, in which case RenameFile matches the filename to existingFileName.

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.

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 the operation.
-5 Invalid path, for either of the filenames.
-6 Access denied.
-7 Specified existing path is a directory, not a file.
-8 Disk is full.
-9 New file already exists.

Additional Information

Library: Utility Library

Include file: utility.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later

Was this information helpful?

Previous

DeleteFile

Previous

DeleteFile