Hello! I have been following Rama’s tutorial on how to write to a text file from UE. ( Link ) It is a very helpful walkthrough, but I am wondering if there is a way to append to the text file instead of writing over what is already there. I have been writing to the file every 10 seconds and make sure to print my the RunTime so I can see that it is indeed overwriting what is currently there. (Spoiler: it is)
The code below has been writing a single line to the file, overwriting what is already there.
FFileHelper::SaveStringToFile(SaveText, * SaveDirectory);
The code below is able to write the string twice on the same line, but I was reading that I have to delete the file handle before quitting my program. Is there an “OnQuit” function available where I can delete it?
IPlatformFile& file = FPlatformFileManager::Get().GetPlatformFile();
IFileHandle* handle = file.OpenWrite(*directory);
if (handle)
{
handle->Write((const uint8*)TCHAR_TO_ANSI(*string), string.Len());
handle->Write((const uint8*)TCHAR_TO_ANSI(*string), string.Len());
delete handle;
}
Also, my string has a
in it but doesn’t seem to add a new line… is there something else I have to add?
All help is greatly appreciated!