@@ -270,18 +270,23 @@ private static Task<IEnumerable<ICloudProvider>> DetectNutstoreDrive()
270
270
string iconPath = Path . Combine ( programFilesFolder , "Nutstore" , "Nutstore.exe" ) ;
271
271
var iconFile = Win32Helper . ExtractSelectedIconsFromDLL ( iconPath , new List < int > ( ) { 101 } ) . FirstOrDefault ( ) ;
272
272
273
- // get every folder under the Nutstore folder in %userprofile%
274
- var mainFolder = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . UserProfile ) , "Nutstore" ) ;
275
- var nutstoreFolders = Directory . GetDirectories ( mainFolder , "Nutstore" , SearchOption . AllDirectories ) ;
276
- foreach ( var nutstoreFolder in nutstoreFolders )
273
+ using var syncRootMangerKey = Registry . LocalMachine . OpenSubKey ( @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SyncRootManager" ) ;
274
+ if ( syncRootMangerKey is not null )
277
275
{
278
- var folderName = Path . GetFileName ( nutstoreFolder ) ;
279
- if ( folderName is not null && folderName . StartsWith ( "Nutstore" , StringComparison . OrdinalIgnoreCase ) )
276
+ var syncRootIds = syncRootMangerKey . GetSubKeyNames ( ) ;
277
+ foreach ( var syncRootId in syncRootIds )
280
278
{
279
+ if ( ! syncRootId . StartsWith ( "Nutstore-" ) ) continue ;
280
+
281
+ var sid = syncRootId . Split ( '!' ) [ 1 ] ;
282
+ using var syncRootKey = syncRootMangerKey . OpenSubKey ( $@ "{ syncRootId } \UserSyncRoots") ;
283
+ var userSyncRoot = syncRootKey ? . GetValue ( sid ) ? . ToString ( ) ;
284
+ if ( string . IsNullOrEmpty ( userSyncRoot ) ) continue ;
285
+
281
286
results . Add ( new CloudProvider ( CloudProviders . Nutstore )
282
287
{
283
288
Name = $ "Nutstore",
284
- SyncFolder = nutstoreFolder ,
289
+ SyncFolder = userSyncRoot ,
285
290
IconData = iconFile ? . IconData
286
291
} ) ;
287
292
}
0 commit comments