# 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 | string | The pathname of the file to rename. existingFileName can contain DOS 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.
newFileName | string | The pathname of the new file name. newFileName can contain DOS wildcard characters '?' and '*,' in which case RenameFile matches the filename to existingFileName.

## Return Value

Name | Type | Description
result | integer | 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.