Skip to content

Commit 74ef46b

Browse files
authored
Fix: Fixed issue with creating shortcuts in libraries (#10913)
1 parent a02a80f commit 74ef46b

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/Files.App/Helpers/UIFilesystemHelpers.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,14 @@ public static void SetHiddenAttributeItem(ListedItem item, bool isHidden, ItemMa
392392

393393
public static async Task CreateShortcutFromDialogAsync(IShellPage associatedInstance)
394394
{
395-
var viewModel = new CreateShortcutDialogViewModel(associatedInstance.FilesystemViewModel.WorkingDirectory);
395+
var currentPath = associatedInstance.FilesystemViewModel.WorkingDirectory;
396+
if (App.LibraryManager.TryGetLibrary(currentPath, out var library) &&
397+
!library.IsEmpty)
398+
{
399+
currentPath = library.DefaultSaveFolder;
400+
}
401+
402+
var viewModel = new CreateShortcutDialogViewModel(currentPath);
396403
var dialogService = Ioc.Default.GetRequiredService<IDialogService>();
397404
await dialogService.ShowDialogAsync(viewModel);
398405
}

src/Files.App/Interacts/BaseLayoutCommandImplementationModel.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,17 @@ public virtual void RenameItem(RoutedEventArgs e)
8484

8585
public virtual async void CreateShortcut(RoutedEventArgs e)
8686
{
87+
var currentPath = associatedInstance.FilesystemViewModel.WorkingDirectory;
88+
if (App.LibraryManager.TryGetLibrary(currentPath, out var library) &&
89+
!library.IsEmpty)
90+
{
91+
currentPath = library.DefaultSaveFolder;
92+
}
93+
8794
foreach (ListedItem selectedItem in SlimContentPage.SelectedItems)
8895
{
89-
var filePath = Path.Combine(associatedInstance.FilesystemViewModel.WorkingDirectory,
90-
string.Format("ShortcutCreateNewSuffix".GetLocalizedResource(), selectedItem.Name) + ".lnk");
96+
var fileName = string.Format("ShortcutCreateNewSuffix".GetLocalizedResource(), selectedItem.Name) + ".lnk";
97+
var filePath = Path.Combine(currentPath, fileName);
9198

9299
await FileOperationsHelpers.CreateOrUpdateLinkAsync(filePath, selectedItem.ItemPath);
93100
}

0 commit comments

Comments
 (0)