private string BrowseAndCheckForPath(ObservableCollection <Installation> installations)
        {
            using (var dialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog())
            {
                dialog.IsFolderPicker = true;
                Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult result = dialog.ShowDialog();

                if (result == CommonFileDialogResult.Ok)
                {
                    string path        = dialog.FileName;
                    var    same_pathed = installations.Where(x => x.Path.TrimEnd('\\') == path.TrimEnd('\\') && x.IsAutodiscoveredInstance == false);
                    if (same_pathed.Count() > 0)
                    {
                        var ans = MessageBox.Show(
                            $"You already have [{path}] in your user-added list. Do you really want to add it again [not recommended]?. Press No if you are not sure what to do.",
                            Branding.MessageBoxHeader, MessageBoxButton.YesNo, MessageBoxImage.Exclamation, MessageBoxResult.No);

                        if (ans == MessageBoxResult.No)
                        {
                            return(null);
                        }
                    }

                    if (!(new Installation(path)).Detected)
                    {
                        var ans = MessageBox.Show(
                            $"Cannot detect any {Branding.TargetProduct} installation in [{path}]. Do you really want to add this path? (No = Select another, Cancel = Add nothing)",
                            Branding.MessageBoxHeader, MessageBoxButton.YesNoCancel, MessageBoxImage.Exclamation, MessageBoxResult.No);

                        if (ans == MessageBoxResult.Cancel)
                        {
                            return(null);
                        }
                        else if (ans == MessageBoxResult.No)
                        {
                            return(BrowseAndCheckForPath(installations));
                        }
                    }

                    return(path);
                }
            }

            return(null);
        }
        private void btnChoosePostInstallCommand_Click(object sender, RoutedEventArgs e)
        {
            bool oldTopMost = this.Topmost;

            this.Topmost = false;

            using (var dialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog())
            {
                dialog.Filters.Add(new CommonFileDialogFilter("Executable files", "*.exe; *.com; *.bat; *.cmd; *.ps1; *.vbs; *.sh; *.ps2; *.jar"));
                dialog.Filters.Add(new CommonFileDialogFilter("All files", "*.*"));


                Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult result = dialog.ShowDialog();

                if (result == CommonFileDialogResult.Ok)
                {
                    txtPostInstallCommand.Text = dialog.FileName;
                }
            }

            this.Topmost = oldTopMost;
        }