diff --git a/src/Files.App/Utils/Cloud/CloudDrivesDetector.cs b/src/Files.App/Utils/Cloud/CloudDrivesDetector.cs index 1f2f8ed9ec79..f60eff34ced8 100644 --- a/src/Files.App/Utils/Cloud/CloudDrivesDetector.cs +++ b/src/Files.App/Utils/Cloud/CloudDrivesDetector.cs @@ -270,18 +270,23 @@ private static Task> DetectNutstoreDrive() string iconPath = Path.Combine(programFilesFolder, "Nutstore", "Nutstore.exe"); var iconFile = Win32Helper.ExtractSelectedIconsFromDLL(iconPath, new List() { 101 }).FirstOrDefault(); - // get every folder under the Nutstore folder in %userprofile% - var mainFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Nutstore"); - var nutstoreFolders = Directory.GetDirectories(mainFolder, "Nutstore", SearchOption.AllDirectories); - foreach (var nutstoreFolder in nutstoreFolders) + using var syncRootMangerKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SyncRootManager"); + if (syncRootMangerKey is not null) { - var folderName = Path.GetFileName(nutstoreFolder); - if (folderName is not null && folderName.StartsWith("Nutstore", StringComparison.OrdinalIgnoreCase)) + var syncRootIds = syncRootMangerKey.GetSubKeyNames(); + foreach (var syncRootId in syncRootIds) { + if (!syncRootId.StartsWith("Nutstore-")) continue; + + var sid = syncRootId.Split('!')[1]; + using var syncRootKey = syncRootMangerKey.OpenSubKey($@"{syncRootId}\UserSyncRoots"); + var userSyncRoot = syncRootKey?.GetValue(sid)?.ToString(); + if (string.IsNullOrEmpty(userSyncRoot)) continue; + results.Add(new CloudProvider(CloudProviders.Nutstore) { Name = $"Nutstore", - SyncFolder = nutstoreFolder, + SyncFolder = userSyncRoot, IconData = iconFile?.IconData }); }