Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Save a text file using Blueprints


I'm working on a content-only project, and I need to save an array of strings to a text file locally.

I know this is possible with Rama's plug-in as I have tried it, however as I understand it, I can't use these plug-ins in a content only game when packaged? I get this error message when the plug-in is enabled and I try package the game: alt text

Is there any other way to do this through blueprints without a plug-in, or how should I be doing it?

Product Version: Not Selected
ramaplugin.png (8.0 kB)
more ▼

asked Sep 09 '14 at 08:56 AM in Using UE4

avatar image

1.8k 49 20 67

avatar image TheMainStark Jul 20 '16 at 07:07 AM

Could I get a bit more dumbed down version on how to execute this?

Where do I go to get to these files and add this text?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Just found this amazingly useful! Thanks so much, yRazaei!

Thought I'd post my code to save anyone who needs this from having to type it all out again. Cant seem to reply to the answer for some reason but all credit goes to yRazaei (except maybe for the typing!)

hope thats ok.


 // Fill out your copyright notice in the Description page of Project Settings.
 #pragma once
 #include "Kismet/BlueprintFunctionLibrary.h"
 #include "Paths.h"
 #include "WriteToFile.generated.h"
 class UWriteToFile : public UBlueprintFunctionLibrary
     UFUNCTION(BlueprintCallable, meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject", FriendlyName = "File-IO"), Category = "WriteToFile")
         static bool FileIO__SaveStringTextToFile(FString SaveDirectory, FString fileName, FString SaveText, bool AllowOverWriting);


 // Fill out your copyright notice in the Description page of Project Settings.
 #include "LeapExamples.h"
 #include "WriteToFile.h"
 UWriteToFile::UWriteToFile(const class FObjectInitializer& PCIP)
 bool UWriteToFile::FileIO__SaveStringTextToFile(FString SaveDirectory, FString fileName, FString SaveText, bool AllowOverWriting)
     FString path;
     path = FPaths::GameDir();
     path += "/my_data";
     if (!FPlatformFileManager::Get().GetPlatformFile().DirectoryExists(*path))
         if (!FPlatformFileManager::Get().GetPlatformFile().DirectoryExists(*path))
             return false;
     path += "/";
     path += fileName;
     if (!AllowOverWriting)
         if (FPlatformFileManager::Get().GetPlatformFile().FileExists(*path))
             return false;
     return FFileHelper::SaveStringToFile(SaveText, *path);
more ▼

answered Apr 07 '15 at 01:43 AM

avatar image

11 2

avatar image TheMainStark Jul 22 '16 at 04:43 AM

Hey, I'm really interested in this but I need a bit more in-depth explanation.

I have done:

File > Add Code

Created the WriteToFile.cpp / .h

Copied and pasted the text, saved.

Went in to Unreal and "Refresh Visual Studio".

Did I miss a compile somewhere? I assume the blueprint node 'UWriteToFile' should now appear?

avatar image Mosel3y Aug 04 '16 at 04:16 PM

It won't work if you just copied and pasted, note that "#include "leapExamples.h" etc. should be replaced with your own project name, have you done this?

avatar image GerardM Aug 04 '16 at 01:47 PM

This is very helpfull for me but sadly I can't get it to work after packaging. :( Could someone help me?

avatar image Mosel3y Aug 04 '16 at 04:14 PM

What is the problem you are having?

avatar image GerardM Aug 05 '16 at 05:06 PM

Well during runtime in the editor the script does save my .txt file. But after packaging it doesn't

avatar image GerardM Aug 08 '16 at 01:26 PM

I think the issue is because of the folder where the file should be saved. Does "path = FPaths::GameDir();" work for packaged games?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Just add these codes to your project code, and then simply call it in the blueprint.

alt text alt text

capture2.png (38.4 kB)
capture1.png (23.2 kB)
more ▼

answered Sep 09 '14 at 03:14 PM

avatar image

314 12 9 36

avatar image Pierdek Sep 09 '14 at 04:50 PM
 lol screenshots with code; ))
avatar image Mosel3y Sep 10 '14 at 08:53 AM

Thanks yRezaei, excuse my ignorance on this, but will this will work if I am working on a blueprint only project? i.e. no code. Do I still have a .h file for my project either way?

avatar image yRezaei Sep 10 '14 at 10:15 AM

The base class and functions for writing text into a file exist in UE4. But unfortunately there is no blueprint callable function to access them. I am afraid, this is the only way, as far as I know.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question