FileClose: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 28: Line 28:


==See also==
==See also==
{{File_Functions}}
{{File_functions}}


[[fileClose]]
[[fileClose]]

Revision as of 07:25, 10 June 2011

Closes a file handled by fileCreate or fileOpen.

Syntax

bool fileClose ( file theFile )

Required arguments

  • theFile: the file handle to close.

Returns

Returns true if succesfully, false otherwise.

Example

This example creates a new text file and writes an string in it.

local newFile = fileCreate("test.txt")              -- Try creating the file.
if newFile then                                       -- Check if was sucessfully created.
    fileWrite(newFile, "This is a test file!") -- Write a text line.
    fileClose(newFile)                                -- Close the file after writing in it.
end

It is important to remember to close the file after done in all operations. Especially if you wrote something in it. If you do not close the file and the resource crash all changes are lost.

See also


fileClose