An Asset
is any piece of content in an Unreal Engine project.
Check if a file exists on a disk
.h
#include "HAL/PlatformFileManager.h" // Core
/**
* Check whether a file exists on the disk
* @param FilePath The path of targeted file, e.g. "C:/Temp/MyFile.txt"
* @param OutInfoMsg Help for action's result
* @return The string content of the file
*/
UFUNCTION(BlueprintCallable)
static bool DoesFileExist(FString FilePath, FString& OutInfoMsg);
.cpp
bool UExampleClass::DoesFileExist(FString FilePath, FString &OutInfoMsg)
{
bool bFileExist = FPlatformFileManager::Get().GetPlatformFile().FileExists(*FilePath);
if(!bFileExist) OutInfoMsg = FString::Printf(TEXT("Error: No File found at: '%s'"), *FilePath);
return bFileExist;
}