Skip to content

Commit 85f1bdc

Browse files
authored
Fixed an issue with loading network drives (#2251)
Fix navigation on network drive root
2 parents 55850d3 + 7cd8325 commit 85f1bdc

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Files/Filesystem/Drives.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ public static async Task<StorageFolderWithPath> GetRootFromPath(string devicePat
353353
return null;
354354
}
355355
var rootPath = Path.GetPathRoot(devicePath);
356-
if (devicePath.StartsWith("\\\\?\\"))
356+
if (devicePath.StartsWith("\\\\?\\")) // USB device
357357
{
358358
// Check among already discovered drives
359359
StorageFolder matchingDrive = App.AppSettings.DrivesManager.Drives.FirstOrDefault(x =>
@@ -384,11 +384,12 @@ public static async Task<StorageFolderWithPath> GetRootFromPath(string devicePat
384384
return new StorageFolderWithPath(matchingDrive, rootPath);
385385
}
386386
}
387+
else if (devicePath.StartsWith("\\\\")) // Network share
388+
{
389+
rootPath = rootPath.LastIndexOf("\\") > 1 ? rootPath.Substring(0, rootPath.LastIndexOf("\\")) : rootPath; // Remove share name
390+
return new StorageFolderWithPath(await StorageFolder.GetFolderFromPathAsync(rootPath), rootPath);
391+
}
387392
// It's ok to return null here, on normal drives StorageFolder.GetFolderFromPathAsync works
388-
//else
389-
//{
390-
// return new StorageFolderWithPath(await StorageFolder.GetFolderFromPathAsync(rootPath), rootPath);
391-
//}
392393
return null;
393394
}
394395

Files/Views/ModernShellPage.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,17 +460,18 @@ public async void CheckPathInput(ItemViewModel instance, string currentInput, st
460460

461461
currentInput = StorageFileExtensions.GetPathWithoutEnvironmentVariable(currentInput);
462462
if (currentSelectedPath == currentInput) return;
463-
var item = await DrivesManager.GetRootFromPath(currentInput);
464463

465464
try
466465
{
466+
var item = await DrivesManager.GetRootFromPath(currentInput);
467467
var pathToNavigate = (await StorageFileExtensions.GetFolderWithPathFromPathAsync(currentInput, item)).Path;
468468
ContentFrame.Navigate(AppSettings.GetLayoutType(), new NavigationArguments() { NavPathParam = pathToNavigate, AssociatedTabInstance = this }); // navigate to folder
469469
}
470470
catch (Exception) // Not a folder or inaccessible
471471
{
472472
try
473473
{
474+
var item = await DrivesManager.GetRootFromPath(currentInput);
474475
var pathToInvoke = (await StorageFileExtensions.GetFileWithPathFromPathAsync(currentInput, item)).Path;
475476
await InteractionOperations.InvokeWin32Component(pathToInvoke);
476477
}

0 commit comments

Comments
 (0)