I want to read text file by C++ std API '“fopen”, it’s successful on Windows, but read failed on Android.
FString projectDir = FPaths::GameDir();
FString path = projectDir + TEXT("Content/Resource/conf/role/Role.conf");
FILE * fp = ::fopen(TCHAR_TO_ANSI(*path), "rb");
as I know, if there are some files should be inclued when Packaging, “Additional Non-asset Directories to Package” should be checked. even I check this setting, fopen still read file failed.
The files are packaged so you cannot use low-level fopen to access them. You need to use the file system. The easiest way is to use LoadFileToString(), for example:
FString Filename = FPaths::GameContentDir() + TEXT("Resource/conf/role/Role.conf");
if (FFileHelper::LoadFileToString(Contents, *Filename))
// do something with Contents
You can look at the code for LoadFileToString() in Engine/Source/Runtime/Core/Private/Misc/CoreMisc.cpp to see how it works.
ok, i see, thanks very much for your suggestions.