Hi, I want to know how many hard drives in PC.
I can iterate files and directories from C: with
IPlatformFile::FDirectoryVisitor
IFileManager::Get().IterateDirectory
But, I don’t know where I can get hard drives list.
Hi, I want to know how many hard drives in PC.
I can iterate files and directories from C: with
IPlatformFile::FDirectoryVisitor
IFileManager::Get().IterateDirectory
But, I don’t know where I can get hard drives list.
In SlateFileDlgWindows.cpp, UE4 call GetLogicalDrives() (windows API) directly.
You don’t want to execute this code in a tick function but it should work fine:
TArray<FString> ALibraryActor::GetDrives()
{
TArray<FString> drives;
FString letters = TEXT("CDEFGHIJKLMNOPQRSTUVWXYZ");
FString drive;
for (int32 i = 0; i < letters.Len(); i++)
{
drive = FString(1, (&letters.GetCharArray()[i]));
drive.Append(TEXT(":/"));
const FString fullPath = FPaths::GetCleanFilename(drive);
const FFileStatData data = FPlatformFileManager::Get().GetPlatformFile().GetStatData(*drive);
if (data.bIsDirectory)
{
drives.Add(drive);
}
}
return drives;
}
Thanks, thebenjiman.