Skip to content

overview

These functions allow you to read and write to files.

moonlight.windows.file.write

Parameters

  • string file
  • string content

Remarks

  • This will create a file if it doesn't exist.
  • This will always completely overwrite an existing file.
  • This will only create a file in the moonlight directory. If you want to write to a subdirectory, see the example below:
moonlight.windows.file.write( "hello.txt", "hello world" )

moonlight.windows.file.read

Parameters

  • string file

Returns

  • string

Remarks

  • This will only read files in the moonlight directory. If you want to read a file in a subdirectory, see the example below:
local script_content = moonlight.windows.file.read( "scripts\\hello.lua" )

moonlight.windows.file.append

Parameters

  • string file
  • string content

Remarks

  • This will only append a file in the moonlight directory. If you want to write to a subdirectory, see the example below:
moonlight.windows.file.append( "hello.txt", "\nthis is my next line" )