Adding array of strings to text file line by line

I was wondering if this was possible as I currently read in strings line by line from a text file using

LoadANSITextFileToStrings(*projectDir, NULL, names);

which reads in an array of strings line by line and then adds them to an existing array in my project.

So is it possible to write to a text file in a similar way that unreal provides?

Thanks in advance!

#Adding String Data Line by Line

You have your core data as

FString StringData = "";

Then you add lines like this

if(StringData != "")
   StringData += "\n"; //newline

//Add new text
StringData += NextLineOfText; //can be FString or TCHAR*

then you write out the String to file using Epic’s function:


FFileHelper::SaveStringToFile(SaveText, * SaveDirectory);

#String Array

if you have an array of string you can use the ranged for each with your array and my code above

TArray<FString> YourData;

for(const FString& EachString : YourData)
  //use code above to add EachString to the total StringData.

#Wiki With More Info

Saving To Text Files


I have one question, what do you mean under “EachString”?