private void DoBrowse() { var openFileDialog = new Microsoft.Win32.OpenFileDialog(); string lastDirectory = Settings.Default.LastOpenDirectory; if (string.IsNullOrEmpty(lastDirectory)) { lastDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); } openFileDialog.InitialDirectory = lastDirectory; openFileDialog.CheckFileExists = true; openFileDialog.Multiselect = false; openFileDialog.Title = "Choose image file..."; openFileDialog.Filter = ""; var result = openFileDialog.ShowDialog(this); if (result.HasValue && result.Value) { Settings.Default.LastOpenDirectory = Path.GetDirectoryName(openFileDialog.FileName); if (!IconManager.AddCustomImage(openFileDialog.FileName, true)) { MessageBox.Show(this, "There is already a custom icon with that file name.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }