Click or drag to resize

FRename Function

Change the name of a file.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.4a
Syntax
 FUNCTION FRename(
	cOldFile AS STRING,
	cNewFile AS STRING
) AS LOGIC
View Source

Parameters

cOldFile
Type: String
The original file name, including an optional drive, directory, and extension.  SetDefault() and SetPath() settings are ignored; the Windows default is used unless you specify a drive and directory as part of the file name.  No extension is assumed.
cNewFile
Type: String
The new file name, including an optional drive, directory, and extension.  SetDefault() and SetPath() settings are ignored; the Windows default is used unless you specify a drive and directory as part of the file name.  No extension is assumed.
If the source directory is different from the target directory, the file moves to the target directory.
If <cNewFile> exists or is currently open, FRename() fails and returns FALSE.

Return Value

Type: Boolean
TRUE if the operation succeeds; otherwise, FALSE.  In the case of a failure, FError() can be used to determine the specific error. Warning!  Files must be closed before renaming.
Attempting to rename an open file will produce unpredictable results.  When a database file is renamed, the associated memo file, if any, must also be renamed.  Failure to do so can compromise the integrity of your databases.
Remarks
Examples
This example demonstrates a file rename:
X#
1IF !FRename("oldfile.txt", "newfile.txt")
2    ? DOSErrString(FError())
3ENDIF
See Also