Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ private async Task LoadFromImagePath()
return;
}

// Reset output path when loading a new image so the picker uses the source folder
OutPutPath = "";

InitialLoadProgressBar.Value = 0;
LoadIconSizes();

Expand Down Expand Up @@ -455,6 +458,27 @@ private async void SaveAllBTN_Click(object sender, RoutedEventArgs e)
savePicker.DefaultFileExtension = ".ico";
savePicker.SuggestedFileName = Path.GetFileNameWithoutExtension(ImagePath);

// If we have a last used output path, try to set it as the suggested save file
// This will make the picker open in that folder
if (!string.IsNullOrWhiteSpace(OutPutPath) && File.Exists(OutPutPath))
{
try
{
StorageFile previousFile = await StorageFile.GetFileFromPathAsync(OutPutPath);
savePicker.SuggestedSaveFile = previousFile;
}
catch
{
// If we can't access the previous file, try using the source image folder
await TrySetSuggestedFolderFromSourceImage(savePicker);
}
}
else
{
// No previous output, use the source image folder
await TrySetSuggestedFolderFromSourceImage(savePicker);
}

InitializeWithWindow.Initialize(savePicker, App.MainWindow.WindowHandle);

StorageFile file = await savePicker.PickSaveFileAsync();
Expand Down Expand Up @@ -497,6 +521,27 @@ private async void SaveBTN_Click(object sender, RoutedEventArgs e)
savePicker.DefaultFileExtension = ".ico";
savePicker.SuggestedFileName = Path.GetFileNameWithoutExtension(ImagePath);

// If we have a last used output path, try to set it as the suggested save file
// This will make the picker open in that folder
if (!string.IsNullOrWhiteSpace(OutPutPath) && File.Exists(OutPutPath))
{
try
{
StorageFile previousFile = await StorageFile.GetFileFromPathAsync(OutPutPath);
savePicker.SuggestedSaveFile = previousFile;
}
catch
{
// If we can't access the previous file, try using the source image folder
await TrySetSuggestedFolderFromSourceImage(savePicker);
}
}
else
{
// No previous output, use the source image folder
await TrySetSuggestedFolderFromSourceImage(savePicker);
}

InitializeWithWindow.Initialize(savePicker, App.MainWindow.WindowHandle);

StorageFile file = await savePicker.PickSaveFileAsync();
Expand Down Expand Up @@ -815,4 +860,25 @@ private async Task PasteImageFromClipboard()
ConfigUiWelcome();
}
}

private async Task TrySetSuggestedFolderFromSourceImage(FileSavePicker savePicker)
{
if (string.IsNullOrWhiteSpace(ImagePath))
return;

try
{
// Use the source image file itself to suggest the folder
// This makes the picker open in the source image's folder
if (File.Exists(ImagePath))
{
StorageFile sourceFile = await StorageFile.GetFileFromPathAsync(ImagePath);
savePicker.SuggestedSaveFile = sourceFile;
}
}
catch
{
// If file access fails, fall back to default picker behavior
}
}
}