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