public bool ChooseNewFolder() { StorageFolder chosenFolder = FolderPicker(excuseFolder); if (chosenFolder != null) { excuseFolder = chosenFolder; return true; } WinForms.MessageBox.Show("No excuse folder chosen!"); return false; }
private string SetCurrentDirectory(StorageFolder storageFolder = null, StorageFile storageFile = null) { if (storageFile == null || string.IsNullOrEmpty(storageFile.Path)) { if (storageFolder == null || string.IsNullOrEmpty(storageFolder.Path)) { return initialDirectory; } else { return storageFolder.Path; } } else { return Path.GetDirectoryName(storageFile.Path); } }
private StorageFile FileOpenPicker(StorageFolder storageFolder = null, StorageFile storageFile = null) { string directory = SetCurrentDirectory(storageFolder, storageFile); string fileName = SetCurrentFileName(storageFile); OpenFileDialog openDialog = new OpenFileDialog() { Title = "Open File", Filter = FILTER, FileName = fileName, InitialDirectory = directory, Multiselect = false, CheckPathExists = true, CheckFileExists = true }; if (openDialog.ShowDialog() == true) { storageFile = new StorageFile(openDialog.FileName); return storageFile; } return null; }
private StorageFile FileSavePicker(StorageFolder storageFolder = null, StorageFile storageFile = null) { string directory = SetCurrentDirectory(storageFolder, storageFile); string fileName = SetCurrentFileName(storageFile); SaveFileDialog saveDialog = new SaveFileDialog() { Title = "Save File", Filter = FILTER, FileName = fileName, InitialDirectory = directory, CheckPathExists = true, CheckFileExists = false }; if (saveDialog.ShowDialog() == true) { storageFile = new StorageFile(saveDialog.FileName); return storageFile; } return null; }
private StorageFolder FolderPicker(StorageFolder storageFolder = null) { string directory = SetCurrentDirectory(storageFolder); WinForms.FolderBrowserDialog openFolder = new WinForms.FolderBrowserDialog() { Description = "Select Folder", ShowNewFolderButton = true, SelectedPath = directory, }; if (openFolder.ShowDialog() == WinForms.DialogResult.OK) { storageFolder = new StorageFolder(openFolder.SelectedPath); return storageFolder; } return null; }