From Multi Theft Auto: Wiki
Revision as of 05:52, 11 August 2019 by Danilo (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Renames the specified file.

[[{{{image}}}|link=|]] Note: Also with this function you can move specified file to a new location, new folder or even to another resource's folder. But for this action executing resource must have 'ModifyOtherObjects' ACL right set to true.


bool fileRename ( string filePath, string newFilePath )

OOP Syntax Help! I don't understand this!

Note: This function is a static function underneath the File class.
Method: File.rename(...)

Required Arguments

  • filePath: The filepath of the source file in the following format: ":resourceName/path". 'resourceName' is the name of the resource the file is in, and 'path' is the path from the root directory of the resource to the file. If the file is in the current resource, only the file path is necessary.
  • newFilePath: Destination filepath for the specified source file in the same format.


If successful, returns true. Otherwise returns false.


This example renames the file test1.txt that is in the root of the current resource to test2.txt.

if fileRename( "test1.txt", "test2.txt" ) then
    outputConsole("File `test1.txt` successfully renamed to `test2.txt`")
    outputConsole("Unable to rename `test1.txt`")

This example moves the file test1.txt that is in the root of the current resource to myFolder folder. If this folder is not exists, it will be created before moving the file test1.txt.

if fileRename( "test1.txt", "myFolder/test1.txt" ) then
    outputConsole("File `test1.txt` successfuly moved to `myFolder` folder")
    outputConsole("Unable to move `test1.txt`")

See Also