private void Button_Click(object sender, RoutedEventArgs e) { var fbd = new WPFFolderBrowserDialog { Title = Application.Current.Resources["SelectedFolder"].ToString(), InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic) }; if (fbd.ShowDialog() == true) SelectedPath = fbd.FileName; }
private void SelectPath_Click(object sender, RoutedEventArgs e) { if (_isInFileMode) { var sfd = new SaveFileDialog { Filter = string.Format("{0}|{1}|MP3|*.mp3|AAC|*.aac|WMA|*.wma", Application.Current.Resources["CopyFromOriginal"], "*" + _defaultExtension), FilterIndex = (int)(DownloadSettings.Format +1), FileName = Path.GetFileName(SelectedPath) }; if (sfd.ShowDialog(this) == true) { SelectedPath = sfd.FileName; DownloadSettings.Format = (AudioFormat)(sfd.FilterIndex -1); if (sfd.FilterIndex > 1) DownloadSettings.IsConverterEnabled = true; OnPropertyChanged("DownloadSettings"); CheckIfFileExists(); } } else { var fbd = new WPFFolderBrowserDialog {InitialDirectory = DownloadSettings.DownloadFolder}; if (fbd.ShowDialog(this) == true) SelectedPath = fbd.FileName; } }
internal bool AddFolder(WindowsVer.Windows windowsOs) { string sendToPath = GetSendToFolderPath(windowsOs); WPFFolderBrowserDialog folderBrowserDialog = new WPFFolderBrowserDialog(); if (folderBrowserDialog.ShowDialog() == true) { string folderPath = folderBrowserDialog.FileName; CreateShortcut(sendToPath, folderPath); return true; } return false; }
private void OnCLickBtnSelectFolder(object sender, RoutedEventArgs e) { var ofd = new WPFFolderBrowserDialog("Select ROOT folder below defaultwidgets folder (i.e. your Default Widget Factory Plugin Guid)") { FileName = Settings.Default.Path }; bool? res = ofd.ShowDialog(this); if (res.HasValue && res.Value) { _path = ofd.FileName; } }
private void Background_Click(object sender, RoutedEventArgs e) { var dlg = new WPFFolderBrowserDialog(); Nullable<bool> result = dlg.ShowDialog(); if (result == true) { var relativePath = dlg.FileName.Substring(dlg.FileName.LastIndexOf("Content\\") + 8); background_txt.Text = relativePath; LoadBackground(relativePath); } }
public override void Execute(object parameter) { var dlg = new WPFFolderBrowserDialog("Select Folder") { AddToMruList = true, DereferenceLinks = true, ShowPlacesList = true }; if (dlg.ShowDialog().GetValueOrDefault()) { Model.OpenFileSystemItems(dlg.FileName); } }
private void SaveLocationChooseButton_OnClick(object sender, RoutedEventArgs e) { /*Get user a Folder Browser to choose.*/ WPFFolderBrowserDialog dialog = new WPFFolderBrowserDialog(); //Start from the previous choosen folder if needed to. if (!string.IsNullOrEmpty(SaveLocationTextBox.Text)) { dialog.InitialDirectory = SaveLocationTextBox.Text; } if (dialog.ShowDialog().GetValueOrDefault()) { SaveLocationTextBox.Text = dialog.FileName + "\\"; } }
private void BrowseForFolder(object sender, RoutedEventArgs e) { var model = ((SettingsWindowModel)FindResource("model")); var dlg = new WPFFolderBrowserDialog("Select Folder") { AddToMruList = true, DereferenceLinks = true, ShowPlacesList = true, InitialDirectory = model.FileSystemMonitorFolder }; if (dlg.ShowDialog().GetValueOrDefault()) { model.FileSystemMonitorFolder = dlg.FileName; } }
private void OnButtonSetupGodModeClick(object sender, RoutedEventArgs e) { WPFFolderBrowserDialog folderBrowserDialog = new WPFFolderBrowserDialog(); if (folderBrowserDialog.ShowDialog() != true) return; string selectedFolderName = folderBrowserDialog.FileName; if (!Directory.Exists(selectedFolderName)) { _message.Error(GetResourceString("DirNotExist")); return; } if (Utils.IsEmptyDirectory(selectedFolderName)) { if (Directory.GetParent(selectedFolderName) != null) { string godModeFolderPath = selectedFolderName + Constants.GodModeKey; if (Directory.Exists(godModeFolderPath)) Directory.Delete(godModeFolderPath); DirectoryInfo selectedFolderDirectoryInfo = new DirectoryInfo(selectedFolderName); string parentDir = selectedFolderDirectoryInfo.Parent.FullName; try { selectedFolderDirectoryInfo.Delete(true); Directory.CreateDirectory(godModeFolderPath); _message.Success(GetResourceString("SuccessfullyFolderCreate") + " " + parentDir + ". " + GetResourceString("PleaseNoteWinRefresh")); } catch (UnauthorizedAccessException) { _message.Error(GetResourceString("PermissionDenied")); } catch (IOException ioe) { _message.Error(ioe.Message); } } else { _message.Error(GetResourceString("YoCantMake") + " " + selectedFolderName + " . " + GetResourceString("AGodFolder") + GetResourceString("PleaseSelectAnEmptyFolderOrCreate")); } } else { _message.Error(selectedFolderName + " " + GetResourceString("IsNotEmptyForGod")); } }
private void OnButtonDeleteSpecialFolderClick(object sender, RoutedEventArgs e) { WPFFolderBrowserDialog folderBrowserDialog = new WPFFolderBrowserDialog(); if (folderBrowserDialog.ShowDialog() == true) { string path = folderBrowserDialog.FileName; string createCmd = String.Format("rd \"\\\\.\\{0}\"", path); ProcessWrapper.ExecuteDosCmd(createCmd); } }
private void OnButtonBrowseSpecialFolderParentClick(object sender, RoutedEventArgs e) { WPFFolderBrowserDialog folderBrowserDlg = new WPFFolderBrowserDialog(); folderBrowserDlg.Title = GetResourceString("SelectParentFolder"); if (folderBrowserDlg.ShowDialog() == true) { string parentPath = folderBrowserDlg.FileName; string createCmd = String.Format("md \"\\\\.\\{0}\\{1}\"", parentPath, cmboBxSpecialFolderNames.SelectionBoxItem); ProcessWrapper.ExecuteDosCmd(createCmd); _message.Success(cmboBxSpecialFolderNames.SelectionBoxItem + " " + GetResourceString("CreatedSuccessFullyAt") + " " + parentPath); } }
private void OnButtonSetupGodModeClick(object sender, RoutedEventArgs e) { WPFFolderBrowserDialog folderBrowserDialog = new WPFFolderBrowserDialog(); if (folderBrowserDialog.ShowDialog() == true) { String selectedFolderName = folderBrowserDialog.FileName; if (Utils.IsEmptyDirectory(selectedFolderName)) { if (Directory.GetParent(selectedFolderName) != null) { String godModeFolderPath = selectedFolderName + Constants.GodModeKey; if (Directory.Exists(godModeFolderPath)) Directory.Delete(godModeFolderPath); DirectoryInfo selectedFolderDirectoryInfo = new DirectoryInfo(selectedFolderName); String parentDir = selectedFolderDirectoryInfo.Parent.FullName; try { selectedFolderDirectoryInfo.Delete(true); Directory.CreateDirectory(godModeFolderPath); MessageBox.Show("God Mode folder has been successfully created in " + parentDir + "\n\nPlease note that if on clicking the folder you get an error, " + "then you need to refresh that window for changes to be reflected.", Constants.SuccessMsgTitle, MessageBoxButton.OK, MessageBoxImage.Information); } catch (UnauthorizedAccessException ex) { MessageBox.Show("Permission Denied!", Constants.ErrorMsgTitle, MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("You can't make " + selectedFolderName + " a \'God\' folder. " + "\n Please select an empty folder or create a new one", Constants.WarningMsgTitle, MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show(selectedFolderName + " is not an empty folder.\n You must create an " + "empty folder, to set God Mode", Constants.WarningMsgTitle, MessageBoxButton.OK, MessageBoxImage.Warning); } } }
private void OnButtonBrowseSpecialFolderParentClick(object sender, RoutedEventArgs e) { WPFFolderBrowserDialog folderBrowserDlg = new WPFFolderBrowserDialog(); folderBrowserDlg.Title = "Select a Parent Folder"; if (folderBrowserDlg.ShowDialog() == true) { String parentPath = folderBrowserDlg.FileName; String createCmd = String.Format("md \"\\\\.\\{0}\\{1}\"", parentPath, cmboBxSpecialFolderNames.SelectionBoxItem); Utils.ExecuteCmd(createCmd); MessageBox.Show(cmboBxSpecialFolderNames.SelectionBoxItem + " created Successfully at " + parentPath, Constants.SuccessMsgTitle, MessageBoxButton.OK, MessageBoxImage.Information); } }