FileRename Procedure

Renames or moves a file.

Syntax

[ lStatus = ] FileRename ( sFileName, sNewFileName )

The FileRename procedure syntax has the following parts:

 

Name

Type

Description

lStatus

Long

Status, 0 for success and <> 0 for failure

sFileName

Val BString

Name of existing file

sNewFileName

Val BString

New file name

Comments

The FileRename function renames a file specified by sFilename to the name given by the sNewFileName. The sFilename must be the path of an existing file. The sNewFileName name must not be the name of an existing file. If the sNewFileName contains a different path from sFilename, the file is moved to a new directory.

This function returns 0 if the procedure was successful or a nonzero value if the function failed.

This function may be used to move files from one directory to another or to rename them. However, files cannot be moved from one device to another (for example, from drive C: to drive A:).

Example

The following example will rename the file name "x.log" to "y.log":

If FileRename(GetLogDir(aGetDirLog)+"\\x.Log", "y.Log") <> 0

Print "Error During FileRename..."

Endif

See Also

FileCreate, FileFind, FileRemove, GetDir