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"

Loading text to a string

I'm trying to load text from a .txt file to a string, to use in my level blueprint. To test this, when pressing the q key some words from my text file should be printed ot the screen. However, nothing happens.

Any ideas where I'm going wrong? Here's the code:


 #include "MuseumProject.h"
 #include "MyBlueprintFunctionLibrary.h"
 // Load and save text files
 bool UMyBlueprintFunctionLibrary::FileSaveString(FString SaveTextB, FString FileNameB)
     return FFileHelper::SaveStringToFile(SaveTextB, *(FPaths::GameDir() + FileNameB));
 bool UMyBlueprintFunctionLibrary::FileLoadString(FString FileNameA, FString& SaveTextA)
     return FFileHelper::LoadFileToString(SaveTextA, *(FPaths::GameDir() + FileNameA));
 FString UMyBlueprintFunctionLibrary::FileLoadAndReturnString(FString FileNameA)
     FString myString;
     bool myBool = true;
     myBool = FFileHelper::LoadFileToString(myString, *(FPaths::GameDir() + FileNameA));
     return myString;


 #pragma once
 #include "Kismet/BlueprintFunctionLibrary.h"
 #include "MyBlueprintFunctionLibrary.generated.h"
 class MUSEUMPROJECT_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
     UFUNCTION(BlueprintCallable, Category = "save")
         static bool FileSaveString(FString SaveTextB, FString FileNameB);
     UFUNCTION(BlueprintPure, Category = "save")
         static bool FileLoadString(FString FileNameA, FString& SaveTextA);
     UFUNCTION(BlueprintCallable, Category = "save")
         static FString FileLoadAndReturnString(FString FileNameA);

The Blueprint alt text

Coding is not my strong point so any help is appreciated.

Thank you! - SB7

Product Version: Not Selected
more ▼

asked Feb 18 '15 at 07:43 PM in C++ Programming

avatar image

36 4 5 7

avatar image Lojo Feb 19 '15 at 09:26 PM

Some debug information would help you and the rest of us get started - If you set a breakpoint within your FileLoadAndReturnString function in C++, is the breakpoint triggered?

If not, you should set a breakpoint on the Q Pressed event node in Blueprint. There are a few things that can screw up input.

Without knowing where things are going wrong, it's harder to offer solutions.

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

1 answer: sort voted first

Nevermind I was an idiot. It turns out the text files have to be in the project directory and not just anywhere on the drive! The code works fine after all, case closed. :)

more ▼

answered Feb 24 '15 at 06:23 PM

avatar image

36 4 5 7

(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