Skip to content

Commit e6ee6bd

Browse files
committed
Fix navigation on network drive root
1 parent 122f2f1 commit e6ee6bd

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
@@ -340,7 +340,7 @@ public static async Task<StorageFolderWithPath> GetRootFromPath(string devicePat
340340
return null;
341341
}
342342
var rootPath = Path.GetPathRoot(devicePath);
343-
if (devicePath.StartsWith("\\\\?\\"))
343+
if (devicePath.StartsWith("\\\\?\\")) // USB device
344344
{
345345
// Check among already discovered drives
346346
StorageFolder matchingDrive = App.AppSettings.DrivesManager.Drives.FirstOrDefault(x =>
@@ -371,11 +371,12 @@ public static async Task<StorageFolderWithPath> GetRootFromPath(string devicePat
371371
return new StorageFolderWithPath(matchingDrive, rootPath);
372372
}
373373
}
374+
else if (devicePath.StartsWith("\\\\")) // Network share
375+
{
376+
rootPath = rootPath.LastIndexOf("\\") > 1 ? rootPath.Substring(0, rootPath.LastIndexOf("\\")) : rootPath; // Remove share name
377+
return new StorageFolderWithPath(await StorageFolder.GetFolderFromPathAsync(rootPath), rootPath);
378+
}
374379
// It's ok to return null here, on normal drives StorageFolder.GetFolderFromPathAsync works
375-
//else
376-
//{
377-
// return new StorageFolderWithPath(await StorageFolder.GetFolderFromPathAsync(rootPath), rootPath);
378-
//}
379380
return null;
380381
}
381382

Files/UserControls/ModernNavigationToolbar.xaml.cs

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

244244
currentInput = StorageFileExtensions.GetPathWithoutEnvironmentVariable(currentInput);
245245
if (currentSelectedPath == currentInput) return;
246-
var item = await DrivesManager.GetRootFromPath(currentInput);
247246

248247
try
249248
{
249+
var item = await DrivesManager.GetRootFromPath(currentInput);
250250
var pathToNavigate = (await StorageFileExtensions.GetFolderWithPathFromPathAsync(currentInput, item)).Path;
251251
App.CurrentInstance.ContentFrame.Navigate(AppSettings.GetLayoutType(), pathToNavigate); // navigate to folder
252252
}
253253
catch (Exception) // Not a folder or inaccessible
254254
{
255255
try
256256
{
257+
var item = await DrivesManager.GetRootFromPath(currentInput);
257258
var pathToInvoke = (await StorageFileExtensions.GetFileWithPathFromPathAsync(currentInput, item)).Path;
258259
await Interaction.InvokeWin32Component(pathToInvoke);
259260
}

0 commit comments

Comments
 (0)