[UE4]读写Text文本时的根目录

读取文本文件:

 FString projectDir = FPaths::GameDir();
 projectDir += "Content/TextFile.txt";
 TArray<FString> StringArray;
 if (!FPlatformFileManager::Get().GetPlatformFile().FileExists(*projectDir))
 {
	 GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("** Could not Find File **"));
	 return;
 }
 FFileHelper::LoadANSITextFileToStrings(*(projectDir), NULL, StringArray);

 

写文件用:

FFileHelper::SaveStringToFile(...);

 

你可能感兴趣的:(UE4)