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

#include "Leadwerks.h"

using namespace Leadwerks;

int main(int argc, const char *argv[])
{
std::string path = "MyFile.txt";
Stream* stream = FileSystem::WriteFile(path);

if (stream)
{
stream->WriteLine("Hello!");
stream->Release();
}

stream = FileSystem::ReadFile(path);
if (stream)
{
System::Print(stream->ReadLine());
stream->Release();
});

return 0;
}