Skip to content

Fix: Fixed issue with creating shortcuts in libraries #10913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Files.App/Helpers/UIFilesystemHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,14 @@ public static void SetHiddenAttributeItem(ListedItem item, bool isHidden, ItemMa

public static async Task CreateShortcutFromDialogAsync(IShellPage associatedInstance)
{
var viewModel = new CreateShortcutDialogViewModel(associatedInstance.FilesystemViewModel.WorkingDirectory);
var currentPath = associatedInstance.FilesystemViewModel.WorkingDirectory;
if (App.LibraryManager.TryGetLibrary(currentPath, out var library) &&
!library.IsEmpty)
{
currentPath = library.DefaultSaveFolder;
}

var viewModel = new CreateShortcutDialogViewModel(currentPath);
var dialogService = Ioc.Default.GetRequiredService<IDialogService>();
await dialogService.ShowDialogAsync(viewModel);
}
Expand Down
11 changes: 9 additions & 2 deletions src/Files.App/Interacts/BaseLayoutCommandImplementationModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,17 @@ public virtual void RenameItem(RoutedEventArgs e)

public virtual async void CreateShortcut(RoutedEventArgs e)
{
var currentPath = associatedInstance.FilesystemViewModel.WorkingDirectory;
if (App.LibraryManager.TryGetLibrary(currentPath, out var library) &&
!library.IsEmpty)
{
currentPath = library.DefaultSaveFolder;
}

foreach (ListedItem selectedItem in SlimContentPage.SelectedItems)
{
var filePath = Path.Combine(associatedInstance.FilesystemViewModel.WorkingDirectory,
string.Format("ShortcutCreateNewSuffix".GetLocalizedResource(), selectedItem.Name) + ".lnk");
var fileName = string.Format("ShortcutCreateNewSuffix".GetLocalizedResource(), selectedItem.Name) + ".lnk";
var filePath = Path.Combine(currentPath, fileName);

await FileOperationsHelpers.CreateOrUpdateLinkAsync(filePath, selectedItem.ItemPath);
}
Expand Down