fileGetSize | Multi Theft Auto: Wiki Skip to content

fileGetSize

Client-side
Server-side
Shared

Returns the total size in bytes of the given file.

OOP Syntax Help! I don't understand this!

  • Method: file:getSize(...)
  • Variable: .size

Syntax

int|false fileGetSize ( file theFile )
Required Arguments
  • theFile: The file handle you wish to get the size of.

Returns

  • int|false: result

Returns the file size if successful, or false if an error occured (e.g. an invalid file handle was passed).

Code Examples

shared
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
local size = fileGetSize(newFile) -- get size
if size then
outputChatBox("Size of test.txt is: "..size, source) -- output size
end
fileClose(newFile) -- close the file once you're done with it
end