---打开资源管理器
UCLASS()
class OPENWINDOWSFILE_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category = "OpenWindowsFile")
static TArray<FString> OpenWindowsFiles();
};
#include "MyBlueprintFunctionLibrary.h"
#include "Runtime\Core\Public\Misc\FileHelper.h"
#include "Runtime\Core\Public\Misc\Paths.h"
#include "Developer\DesktopPlatform\Public\IDesktopPlatform.h"
#include "Developer\DesktopPlatform\Public\DesktopPlatformModule.h"
TArray<FString> UMyBlueprintFunctionLibrary::OpenWindowsFiles() {
TArray<FString> OpenFileNames;//获取的文件绝对路径
FString ExtensionStr=TEXT("*.*");//文件类型
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
DesktopPlatform->OpenFileDialog(nullptr, TEXT("ywy文件管理器"), FPaths::ConvertRelativePathToFull(FPaths::ProjectDir()), TEXT(""), *ExtensionStr, EFileDialogFlags::None, OpenFileNames);
return OpenFileNames;
}