# Save TArray to text file

**URL:** <https://forums.unrealengine.com/t/save-tarray-to-text-file/475642>\
**Category:** Community & Industry Discussion\
**Tags:** tarray, unreal-engine, file, question\
**Created:** [December 8, 2020, 10:56pm UTC](https://forums.unrealengine.com/t/save-tarray-to-text-file/475642 "2020-12-08T22:56:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AgentArachnid66](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AgentArachnid66](https://forums.unrealengine.com/u/AgentArachnid66)\
**Post date:** [December 8, 2020, 10:56pm UTC](https://forums.unrealengine.com/t/save-tarray-to-text-file/475642/1 "2020-12-08T22:56:19Z")

</div>

I’m trying to write a class that will need to write an array of strings to a text file and also read from that same file. I’ve done some debugging and have no idea what’s wrong with it. I tested it with a SaveStringToFile and that worked, but I need to save the array. Here is the function:

.h

> FString dataPath = “testArray.txt”;  
> TArray currentData;

.cpp

```
void ALeapNeuralNet::SaveFile()
{
	FString len = FString::FromInt(currentData.Num());
	UE_LOG(LogTemp, Warning, TEXT("Length of data array: %s"), *len);
	bool success = FFileHelper::SaveStringArrayToFile(currentData, *dataPath);
	FString result = success ? ("Successful") : ("Failed");
	UE_LOG(LogTemp, Warning, TEXT("Saved File: %s"), *result);
	FString dir = FPaths::ProjectDir() + dataPath;
	UE_LOG(LogTemp, Warning, TEXT("Saved to: %s"), *dir);
}

```

Output:

```
Length of Array: 80
Saved File: Successful
Saved to: Expected Location

```

---

<div class="post-metadata">

**Author:** ![Lardo\_Deepdelver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lardo\_Deepdelver](https://forums.unrealengine.com/u/Lardo_Deepdelver)\
**Post date:** [December 9, 2020, 6:21pm UTC](https://forums.unrealengine.com/t/save-tarray-to-text-file/475642/2 "2020-12-09T18:21:55Z")

</div>

have you searched for the file?

reading over the code I would expect it to land somewhere else since you are not using **dir** to save it

```
	const FString OutputDirectory = FPaths::Combine(*FPaths::ProjectDir(), TEXT("Saved"), TEXT("TimedDataMonitor"));
	const FString Filename = TEXT("SomeName")
	const FString FullyQualifiedFileNameFilename = FPaths::Combine(OutputDirectory, Filename);
	FFileHelper::SaveStringArrayToFile(Item.Value.Entries, *FullyQualifiedFileNameFilename);

```

example modivied from unreal code in  
void UTimedDataMonitorSubsystem::UpdateStatFileLoggingState()
