WriteFile

This function creates a new file and opens it with write access. If the file already exists, it will be overwritten.

Syntax

Parameters

Returns

Returns a new stream if the file was able to be written, otherwise NULL is returned.

Remarks

This function will return NULL if Lua sandboxing is enabled.

Example

local path = "MyFile.txt" 
local stream = FileSystem:WriteFile(path)

if (stream) then

stream:WriteLine("Hello!")
stream:Release()
end

stream = FileSystem:ReadFile(path)
if (stream) then

System:Print(stream:ReadLine())
stream:Release()
end