File

File is not creatable, there's only one instance of it. It can only be accessed through its globally exposed variable.

File allows the script to read a file from a user's device.

Functions

Returns the selected file's Data through the result argument of the provided callback. The function is called once the user has chosen a file.

File:OpenAndReadAll(function(success, result)
  -- success is a boolean
  if not success then
    print("Could not read file")
    return
  end

  -- the user has cancelled the file selection
  if result == nil then
    print("No file selected")
    return
  end

  -- result is a Data instance
  local str = result:ToString()
  if string.sub(str, 1, 6) == "CUBZH!" then
    print("It's a Cubzh file!")
  end
end)