This function loads a file from a path and returns a stream.
| Parameter | Descriptio |
|---|---|
| path | file name or URL to load |
| flags | optional load settings |
Returns a new Stream object If the file was successfully read, otherwise nil is returned.
local path = GetPath(PATH_DOCUMENTS) .. "/temp.txt";
--Write a new file
local stream = WriteFile(path);
if stream == nil then
Print("Failed to write file.");
return
end
stream:WriteLine("Hello, world!");
stream:Close();
stream = ReadFile(path);
Print(stream:ReadLine());