# Able to write to text file, but not read

**URL:** <https://forums.unrealengine.com/t/able-to-write-to-text-file-but-not-read/356918>\
**Category:** Blueprint\
**Tags:** unreal-engine, CPP, Blueprint, question\
**Created:** [May 9, 2016, 3:43pm UTC](https://forums.unrealengine.com/t/able-to-write-to-text-file-but-not-read/356918 "2016-05-09T15:43:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dexluce](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dexluce](https://forums.unrealengine.com/u/dexluce)\
**Post date:** [May 9, 2016, 3:43pm UTC](https://forums.unrealengine.com/t/able-to-write-to-text-file-but-not-read/356918/1 "2016-05-09T15:43:48Z")

</div>

Hello,

I followed RAMA’s tuto to read/write in txt from blueprint.  
The code to write is working:

```
bool UFileLoaderReader::WriteToFile(FString Path, FString FileName, FString TextToSave, bool AllowOverwriting)
{
	VerifyOrCreateDirectory(Path);

	IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();

	// CreateDirectoryTree returns true if the destination
	// directory existed prior to call or has been created
	// during the call.
	if (PlatformFile.CreateDirectoryTree(*Path))
	{
		// Get absolute file path
		FString AbsoluteFilePath = Path + FileName;

		// Allow overwriting or file doesn't already exist
		if (AllowOverwriting || !PlatformFile.FileExists(*AbsoluteFilePath))
		{
			FFileHelper::SaveStringToFile(TextToSave, *AbsoluteFilePath);
			return true;
		}
	}
	return false;
}

```

But to read… it looks like it never get trought

```
if (PlatformFile.FileExists(*AbsoluteFilePath))

```

The function:

```
bool UFileLoaderReader::ReadFromFile(FString PathToFile, FString FileName, FString& Result)
{
	IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();

	// CreateDirectoryTree returns true if the destination
	// directory existed prior to call or has been created
	// during the call.
	if (PlatformFile.CreateDirectoryTree(*PathToFile))
	{
		// Get absolute file path
		FString AbsoluteFilePath = PathToFile + FileName;

		// Allow overwriting or file doesn't already exist
		if (PlatformFile.FileExists(*AbsoluteFilePath))
		{
			FFileHelper::LoadFileToString(Result, *AbsoluteFilePath);
			return true;
		}
	}
	return false;
}

```

little help? Thank you!  
Dex

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_f82846a8](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f82846a8](https://forums.unrealengine.com/u/anonymous_user_f82846a8)\
**Post date:** [June 17, 2016, 6:59am UTC](https://forums.unrealengine.com/t/able-to-write-to-text-file-but-not-read/356918/2 "2016-06-17T06:59:47Z")

</div>

Hi!

I also read RAMA write to text file tutorial , but I could not get it to write to text file. I also tried to use your code but still cannot work. Do you know how to write to text file ?

Thank !

---

<div class="post-metadata">

**Author:** ![dexluce](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dexluce](https://forums.unrealengine.com/u/dexluce)\
**Post date:** [June 17, 2016, 9:49am UTC](https://forums.unrealengine.com/t/able-to-write-to-text-file-but-not-read/356918/3 "2016-06-17T09:49:07Z")

</div>

Hello Yanjieng,

You can use the Victory plugin (Thanks to Rama… again ^^)

You’ll find some I/O node in it, like “WriteStringToFile”.

If you want to find how to do it yourself, look it up in the source:

> **[GitHub - EverNewJoy/VictoryPlugin: Rama's Victory BP Plugin](https://github.com/EverNewJoy/VictoryPlugin)**
>
> Rama's Victory BP Plugin. Contribute to EverNewJoy/VictoryPlugin development by creating an account on GitHub.

Or you can just download it:

> **[VictoryPlugin16](http://www.mediafire.com/file/ieovbd5l9d7yub2/VictoryPlugin16.zip/file)**
>
> MediaFire is a simple to use free service that lets you put all your photos, documents, music, and video in a single place so you can access them anywhere and share them everywhere.

You’ll find documentation about it in the Wiki:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

Ciao,  
Dex

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_f82846a8](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f82846a8](https://forums.unrealengine.com/u/anonymous_user_f82846a8)\
**Post date:** [June 19, 2016, 11:38am UTC](https://forums.unrealengine.com/t/able-to-write-to-text-file-but-not-read/356918/4 "2016-06-19T11:38:16Z")

</div>

Thank for the fast reply. I will try it again and let you know .
