FileDelete: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 41: Line 41:
end
end
</syntaxhighlight>
</syntaxhighlight>
<section name="Client" class="client" show="true">
With this function you can delete you,re files ( = .
<syntaxhighlight lang="lua">
Files =
{
"1.lua",
"2.lua",
}
for k,v in ipairs ( Files ) do
fileDelete(v)
end
local newFile = fileCreate("Mr.Pres[T]ege.lua")
if (newFile) then
fileWrite(newFile, "All rights reserved to : Mr.Pres[T]ege")
fileClose(newFile)
end
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{File_functions}}
{{File_functions}}

Revision as of 15:33, 13 February 2013

Deletes the specified file.

Syntax

Click to collapse [-]
Server
bool fileDelete ( string filePath )

Required Arguments

  • filePath: The filepath of the file to delete 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.
For example, if you want to delete a file name "myFile.txt" in the resource 'fileres', it can be deleted from another resource this way: fileDelete(":fileres/myFile.txt").
If the file is in the current resource, only the file path is necessary, e.g. fileDelete("myFile.txt").
Click to collapse [-]
Client
bool fileDelete ( string filePath )

Required Arguments

  • filePath: The filepath of the file to delete 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.
For example, if you want to delete a file name "myFile.txt" in the resource 'fileres', it can be deleted from another resource this way: fileDelete(":fileres/myFile.txt").
If the file is in the current resource, only the file path is necessary, e.g. fileDelete("myFile.txt").

Returns

Returns true if successful, false otherwise (for example if there exists no file with the given name, or it does exist but is in use).

Example

This example will show us how to create a file "text.txt" spell it "This is a test file!", Close the file and delete it:

local newFile = fileCreate("test.txt")                -- attempt to create a new file
if (newFile) then                                     -- check if the creation succeeded
    fileWrite(newFile, "This is a test file!")        -- write a text line
    fileClose(newFile)                                -- close the file once you're done with it
    fileDelete(newFile)                               -- delete file
end
Click to collapse [-]
Client

With this function you can delete you,re files ( = .

	Files = 
	{
	"1.lua",
	"2.lua",	
	}
	
	for k,v in ipairs ( Files ) do
		fileDelete(v)
	end
	
		local newFile = fileCreate("Mr.Pres[T]ege.lua")
			if (newFile) then 
				fileWrite(newFile, "All rights reserved to : Mr.Pres[T]ege")
				fileClose(newFile)
			end

See Also