fileRename | Multi Theft Auto: Wiki Skip to content

fileRename

Client-side
Server-side
Shared

Renames the specified file.

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.

OOP Syntax Help! I don't understand this!

  • Method: file:rename(...)

Syntax

bool fileRename ( string filePath, string newFilePath )
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.

Returns

  • bool: result

If successful, returns true. Otherwise returns false.

Code Examples

shared

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`")
else
outputConsole("Unable to rename `test1.txt`")
end