@@ -326,15 +326,17 @@ public static void SetLayoutPreferencesForPath(string folderPath, LayoutPreferen
326326 if ( ! userSettingsService . FoldersSettingsService . SyncFolderPreferencesAcrossDirectories )
327327 {
328328 var folderFRN = NativeFileOperationsHelper . GetFolderFRN ( folderPath ) ;
329- WriteLayoutPreferencesToDb ( folderPath . TrimPath ( ) , folderFRN , prefs ) ;
329+ var trimmedFolderPath = folderPath . TrimPath ( ) ;
330+ if ( trimmedFolderPath is not null )
331+ WriteLayoutPreferencesToDb ( trimmedFolderPath , folderFRN , prefs ) ;
330332 }
331333 else
332334 {
333335 userSettingsService . FoldersSettingsService . DefaultLayoutMode = prefs . LayoutMode ;
334336 userSettingsService . LayoutSettingsService . DefaultGridViewSize = prefs . GridViewSize ;
335337
336338 // Do not save options which only work in recycle bin or cloud folders or search results as global
337- if ( prefs . DirectorySortOption != SortOption . Path &&
339+ if ( prefs . DirectorySortOption != SortOption . Path &&
338340 prefs . DirectorySortOption != SortOption . OriginalFolder &&
339341 prefs . DirectorySortOption != SortOption . DateDeleted &&
340342 prefs . DirectorySortOption != SortOption . SyncStatus )
@@ -460,7 +462,8 @@ private static LayoutPreferences GetDefaultLayoutPreferences(string folderPath)
460462
461463 if ( folderPath == Constants . UserEnvironmentPaths . DownloadsPath )
462464 // Default for downloads folder is to group by date created
463- return new LayoutPreferences ( ) {
465+ return new LayoutPreferences ( )
466+ {
464467 DirectoryGroupOption = GroupOption . DateCreated ,
465468 DirectoryGroupDirection = SortDirection . Descending ,
466469 DirectoryGroupByDateUnit = GroupByDateUnit . Year
0 commit comments