# How can I load text from file with blueprint?

**URL:** <https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750>\
**Category:** UI\
**Tags:** text, unreal-engine, file, Blueprint, question\
**Created:** [October 20, 2014, 8:05pm UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750 "2014-10-20T20:05:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nevermore](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nevermore](https://forums.unrealengine.com/u/Nevermore)\
**Post date:** [October 20, 2014, 8:05pm UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/1 "2014-10-20T20:05:26Z")

</div>

Hello, I want to load texts from .txt files using blueprints. Any way I can do it?

---

<div class="post-metadata">

**Author:** ![ScottSpadea](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/scottspadea/32/1194682_2.png) [@ScottSpadea](https://forums.unrealengine.com/u/ScottSpadea)\
**Post date:** [October 21, 2014, 4:27am UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/2 "2014-10-21T04:27:35Z")

</div>

you can make blueprint nodes for saving and loading text files:  
add code to your project inheriting from blueprintFunctionLibrary.

## yourBlueprintFunctionLibrary.CPP

```
bool UyourBlueprintFunctionLibrary::FileSaveString(FString SaveTextB, FString FileNameB)
{
	return FFileHelper::SaveStringToFile(SaveTextB, *(FPaths::GameDir() + FileNameB));
}

bool UyourBlueprintFunctionLibrary::FileLoadString(FString FileNameA, FString& SaveTextA)
{
	return FFileHelper::LoadFileToString(SaveTextA, *(FPaths::GameDir() + FileNameA));
}

```

## yourBlueprintFunctionLibrary.h

```
UFUNCTION(BlueprintCallable, Category = "save")
	static bool FileSaveString(FString SaveTextB, FString FileNameB);

UFUNCTION(BlueprintPure, Category = "save")
	static bool FileLoadString(FString FileNameA, FString& SaveTextA);

```

---

<div class="post-metadata">

**Author:** ![Nevermore](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nevermore](https://forums.unrealengine.com/u/Nevermore)\
**Post date:** [October 21, 2014, 1:37pm UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/3 "2014-10-21T13:37:17Z")

</div>

Thanks for the answer! I have succesfully added code to my project but new node is not showing when I try to add it.

---

<div class="post-metadata">

**Author:** ![ScottSpadea](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/scottspadea/32/1194682_2.png) [@ScottSpadea](https://forums.unrealengine.com/u/ScottSpadea)\
**Post date:** [October 21, 2014, 6:16pm UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/4 "2014-10-21T18:16:15Z")

</div>

if you added that code to your custom blueprintFunctionLibrary and compiled it, you should be able to access those nodes from any blueprint graph by searching for the “save” category, which should contain 2 functions named FileLoadString and FileSaveString.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_9a5e8f16](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_9a5e8f16](https://forums.unrealengine.com/u/anonymous_user_9a5e8f16)\
**Post date:** [August 9, 2015, 4:06pm UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/5 "2015-08-09T16:06:40Z")

</div>

I’m having trouble with this. Do you add this to code on the project or somewhare in the engine source code? And where exactly should this file be saved  
Thanks for your time

---

<div class="post-metadata">

**Author:** ![Mhousse1247](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mhousse1247](https://forums.unrealengine.com/u/Mhousse1247)\
**Post date:** [August 9, 2015, 4:46pm UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/6 "2015-08-09T16:46:30Z")

</div>

Create a new c++ class “yourBlueprintFunctionLibrary” derived from UBlueprintFunctionLibrary and add the code to it

---

<div class="post-metadata">

**Author:** ![Genova](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Genova](https://forums.unrealengine.com/u/Genova)\
**Post date:** [August 13, 2015, 3:05am UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/7 "2015-08-13T03:05:06Z")

</div>

That’s cool 🙂

How would the code looks like if I wanted to write multiple lines instead of everything on the same one?

And same for the the Read, i’d like to make a list out of the texts

---

<div class="post-metadata">

**Author:** ![showpixel](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/showpixel/32/468801_2.png) [@showpixel](https://forums.unrealengine.com/u/showpixel)\
**Post date:** [August 30, 2015, 11:24am UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/8 "2015-08-30T11:24:13Z")

</div>

Hello, i have no clue about c++, but i would like to load a string from a file into the engine with blueprints.  
Following this instructions, i have added a new c++ class “yourBlueprintFunctionLibrary”, added the code at the end of the \*.h and \*.cpp file.  
When compiling, i am getting an error “no class or namespace”,  
in Microsoft Visual Studio Express 2013, i see

 ![56373-screen_01.gif](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/b/1/cb1f7d35a1975265eb724a89deb74d233af87822.gif)

 ![56374-screen_02.gif](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/9/2/6927f3070d2ccb2d4ce7d03c36e3597baec36e86.gif)

 ![56375-screen_03.gif](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/6/1/36103b34776e5c7b701494a42af921b10e1f67f0.gif)

What am i doing wrong? I am working on 4.83, windows 8 64bit.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_9a5e8f16](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_9a5e8f16](https://forums.unrealengine.com/u/anonymous_user_9a5e8f16)\
**Post date:** [August 30, 2015, 12:07pm UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/9 "2015-08-30T12:07:32Z")

</div>

Hi there. I found the problem  
Your file name is MyBlueprintFunctionLibrary and if you look at the code in the cpp file you wil see bool UyourBlueprintFunctionLibrary. Change that to the file name of your blueprint which in your case would be UMyBlueprintFunctionLibrary  
Hope this helps post again if you still need furthur help on this

---

<div class="post-metadata">

**Author:** ![showpixel](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/showpixel/32/468801_2.png) [@showpixel](https://forums.unrealengine.com/u/showpixel)\
**Post date:** [August 30, 2015, 2:42pm UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/10 "2015-08-30T14:42:56Z")

</div>

Yes! That was it! Thanks a lot 🙂

---

<div class="post-metadata">

**Author:** ![Shrooblord](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shrooblord/32/88712_2.png) [@Shrooblord](https://forums.unrealengine.com/u/Shrooblord)\
**Post date:** [September 5, 2015, 9:49am UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/11 "2015-09-05T09:49:20Z")

</div>

I tried to replicate the code shown in showpixel’s question visible above, but I get the following errors (see screenshots). It doesn’t accept my class definition for T\_LOAD\_IT\_API. It also doesn’t like UMyBlueprintFunctionLibrary even though the file names are MyBlueprintFunctionLibrary.h and MyBlueprintFunctionLibrary.cpp .

It throws the same exceptions with the ‘class constructor’ and ‘class destructor’ lines commented out; they were added there by UE4 automatically. Also putting them after the bools doesn’t help (and seems like an illogical order for those lines of code to be in if you ask me).

---

<div class="post-metadata">

**Author:** ![showpixel](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/showpixel/32/468801_2.png) [@showpixel](https://forums.unrealengine.com/u/showpixel)\
**Post date:** [September 6, 2015, 9:23am UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/12 "2015-09-06T09:23:43Z")

</div>

Hi Shrooblord,  
i must say first that i have no clue about c++ programming.  
But i did need to change the \*.cpp code to make it work.  
Please check the image (left side is your code , the right shows my code)

Best Regards!

 ![57386-class_02.gif](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/3/5/7351ebe89414c2efee36cc527ec2e624141b4698.gif)

---

<div class="post-metadata">

**Author:** ![Shrooblord](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shrooblord/32/88712_2.png) [@Shrooblord](https://forums.unrealengine.com/u/Shrooblord)\
**Post date:** [September 6, 2015, 10:47pm UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/13 "2015-09-06T22:47:32Z")

</div>

So your including the t\_load\_it.h header file. But that’s, I assume, the name of your project right? The name of my project is FTL\_Overdrive and as such I include the FTL\_Overdrive.h header file. Was I not supposed to do that? Is the t\_load\_it.h an Epic-native Engine header file?

---

<div class="post-metadata">

**Author:** ![showpixel](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/showpixel/32/468801_2.png) [@showpixel](https://forums.unrealengine.com/u/showpixel)\
**Post date:** [September 7, 2015, 12:30am UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/14 "2015-09-07T00:30:43Z")

</div>

Yes. I generated it exactly as mentioned above.

---

<div class="post-metadata">

**Author:** ![Shrooblord](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shrooblord/32/88712_2.png) [@Shrooblord](https://forums.unrealengine.com/u/Shrooblord)\
**Post date:** [September 7, 2015, 12:59pm UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/15 "2015-09-07T12:59:14Z")

</div>

That doesn’t work for me. I also don’t see what else is different about your code or mine. Note that the code on the left you display is not my code as you said, but rather the code mentioned further up in the page where there’s the typo “UyourBlueprintFunctionLibrary” instead of “UMyBlueprintFunctionLibrary”. I don’t have that typo in my files. See the screenshot I supplied above.

So the code still won’t compile (since there’s been no changes made to it…)

---

<div class="post-metadata">

**Author:** ![Valkyrie\_Sound](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Valkyrie\_Sound](https://forums.unrealengine.com/u/Valkyrie_Sound)\
**Post date:** [January 5, 2017, 9:28pm UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/16 "2017-01-05T21:28:44Z")

</div>

Excellent, _but!_ I had to add `public:` after `GENERATED_BODY()` to be able to use the load function, like this:

```
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "Kismet/BlueprintFunctionLibrary.h"
#include "MyBlueprintFunctionLibrary.generated.h"

/**
 * 
 */
UCLASS()
class DEMO2016_2_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()public:
	
		UFUNCTION(BlueprintCallable, Category = "save")
		static bool FileSaveString(FString SaveTextB, FString FileNameB);

	UFUNCTION(BlueprintPure, Category = "save")
		static bool FileLoadString(FString FileNameA, FString& SaveTextA);
	
	
};

```

Also bear in mind that the File Load String function will automatically search for files in the root directory, where your Content folder is on your drive.

 ![120970-filestringsaveload.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/a/1/7a1820e1b90e16213e35e42829859524965f8214.jpeg)

---

<div class="post-metadata">

**Author:** ![ZoltanE](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ZoltanE](https://forums.unrealengine.com/u/ZoltanE)\
**Post date:** [September 11, 2019, 3:43pm UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/17 "2019-09-11T15:43:00Z")

</div>

I’m on 4.22 and the source compiles fine but the functions don’t show up. What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Estape](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/estape/32/1007455_2.png) [@Estape](https://forums.unrealengine.com/u/Estape)\
**Post date:** [September 11, 2019, 7:15pm UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/18 "2019-09-11T19:15:21Z")

</div>

Try this on top in .cpp file

```
#include "Misc/FileHelper.h"
#include "Misc/Paths.h"
```

---

<div class="post-metadata">

**Author:** ![Jacobm343hp](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jacobm343hp](https://forums.unrealengine.com/u/Jacobm343hp)\
**Post date:** [October 30, 2019, 8:13pm UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/19 "2019-10-30T20:13:36Z")

</div>

Is there a way to delete the file? I can’t find any function for that in FFileHelper

---

<div class="post-metadata">

**Author:** ![maxwell\_taylor](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/maxwell_taylor/32/738641_2.png) [@maxwell\_taylor](https://forums.unrealengine.com/u/maxwell_taylor)\
**Post date:** [September 20, 2023, 2:16am UTC](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750/20 "2023-09-20T02:16:22Z")

</div>

We have a ready-made plugin available that can provide a solution.

> **[File Master-Runtime Load Image & Sound & Text in Code Plugins - UE...](https://www.unrealengine.com/marketplace/en-US/product/blueprint-file-master)**
>
> Designed for Blueprints, this plugin allows for easy downloading/loading of images, sounds, and text files through Blueprint nodes. It offers a comprehensive suite of file operations, providing user-friendly and powerful functionality for runtime...

[Next page](https://forums.unrealengine.com/t/how-can-i-load-text-from-file-with-blueprint/296750.md?page=2)
