# Why is this creating folders instead of text files?

**URL:** <https://forums.unrealengine.com/t/why-is-this-creating-folders-instead-of-text-files/491565>\
**Category:** C++\
**Tags:** saved-folders, unreal-engine, question\
**Created:** [December 3, 2021, 7:21am UTC](https://forums.unrealengine.com/t/why-is-this-creating-folders-instead-of-text-files/491565 "2021-12-03T07:21:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DrewB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DrewB](https://forums.unrealengine.com/u/DrewB)\
**Post date:** [December 3, 2021, 7:21am UTC](https://forums.unrealengine.com/t/why-is-this-creating-folders-instead-of-text-files/491565/1 "2021-12-03T07:21:44Z")

</div>

bool UPMTextFileSave::SaveArrayText(FString SaveDirectory, FString FileName, TArray SaveText, bool AllowOverWriting = false)  
{  
SaveDirectory += “\”;  
SaveDirectory += FileName;

```
if (AllowOverWriting)
{
	if (FPlatformFileManager::Get().GetPlatformFile().FileExists(*SaveDirectory))
	{
		return false;
	}
}
		FString FinalString = "";
		for (FString& Each : SaveText)
		{
			FinalString += Each;
			FinalString += LINE_TERMINATOR;
		}
			return FFileHelper::SaveStringToFile(FinalString, *SaveDirectory);

```

}

* * *

For some reason, if there is an absent file name it will create one randomly sometimes the file named “.txt” will be a text file and sometimes it will be a folder named “.txt” I cannot figure out why and as a novice coder could use some help. The issue is… once the folder is created it is not able to be read or saved to as a “.txt” text file!

---

<div class="post-metadata">

**Author:** ![DrewB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DrewB](https://forums.unrealengine.com/u/DrewB)\
**Post date:** [December 3, 2021, 7:47am UTC](https://forums.unrealengine.com/t/why-is-this-creating-folders-instead-of-text-files/491565/2 "2021-12-03T07:47:13Z")

</div>

UFUNCTION(BlueprintCallable, Category = “Custom”, meta = (Keywords = “Load”))  
static FString LoadFileToString(FString SaveDirectory, FString FileName);

```
	UFUNCTION(BlueprintCallable, Category = "Custom", meta = (Keywords = "Load"))
	static TArray<FString> LoadFileToStringArray(FString SaveDirectory, FString FileName);

```

This was the problem! Do not load files before you write them!
