/// <summary> /// Ask the user where logs should be saved /// </summary> /// <param name="path">folder to save logs to</param> /// <returns>ok/cancel</returns> DialogResult IUserInterface.PromptForLoggingFolder(out string path) { //string initialPath = Environment.CurrentDirectory; Shell32.ShellClass shell = new Shell32.ShellClass(); Shell32.Folder2 folder = (Shell32.Folder2)shell.BrowseForFolder( this.Handle.ToInt32(), "Select Folder...", 0, // Options this.lumberjack.Settings.LogFolderPath ); path = folder.Self.Path; this.folderLabel.Text = path; /* * OpenFileDialog dialog = new OpenFileDialog(); * dialog.CheckPathExists = true; * dialog.InitialDirectory = Settings.Default.LogFolderPath; * dialog.ValidateNames = true; * DialogResult result = dialog.ShowDialog(this); * if (result == DialogResult.OK) * { * string path = dialog.FileName; * path = Path.GetDirectoryName(path); * Settings.Default.LogFolderPath = path; * } */ //Environment.CurrentDirectory = initialPath; return(DialogResult.OK); // TODO: really? }
private void outputDirectoryButton_Click(object sender, System.EventArgs e) { Shell32.Shell shell = new Shell32.ShellClass(); Shell32.Folder folder = shell.BrowseForFolder(this.Handle.ToInt32(), "Select a directory to share. That directory and all sub-folders will also be made available on the network.", 1, null); string directoryString = null; if (folder != null) { if (folder.ParentFolder != null) { for (int i = 0; i < folder.ParentFolder.Items().Count; i++) { if (folder.ParentFolder.Items().Item(i).IsFolder) { if (((Shell32.Folder)(folder.ParentFolder.Items().Item(i).GetFolder)).Title == folder.Title) { directoryString = folder.ParentFolder.Items().Item(i).Path; break; } } } } if (directoryString == null || directoryString.StartsWith("::") == true) { MessageBox.Show(this, "Invalid folder", "Output Folder", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { outputPathTextBox.Text = directoryString; } } }
private void browse_Click(object sender, EventArgs e) { string strPath; string strCaption = "Select a directory."; DialogResult dlgResult; Shell32.ShellClass shl = new Shell32.ShellClass(); Shell32.Folder2 fld = (Shell32.Folder2)shl.BrowseForFolder(0, strCaption, 0, System.Reflection.Missing.Value); if (fld == null) { strPath = ""; dlgResult = DialogResult.Cancel; } else { strPath = fld.Self.Path; dlgResult = DialogResult.OK; } if( !strPath.EndsWith("\\") ) { strPath = strPath + "\\"; } if (dlgResult == DialogResult.OK) { comboBox1.Text = strPath; } }
private void button3_Click(object sender, EventArgs e) { Shell32.ShellClass shl = new Shell32.ShellClass(); Shell32.Folder2 fld = (Shell32.Folder2)shl.BrowseForFolder(0, "Output folder for extracted files", 0, System.Reflection.Missing.Value); if (fld != null) { textBox3.Text = fld.Self.Path; } //fld.Self.Path }
private void button1_Click(object sender, EventArgs e) { Shell32.ShellClass shl = new Shell32.ShellClass(); Shell32.Folder2 fld = (Shell32.Folder2)shl.BrowseForFolder(0, "NZB Folder (eg. your download folder)", 0, System.Reflection.Missing.Value); if (fld != null) { textBox1.Text = fld.Self.Path; } //fld.Self.Path }
private void button2_Click(object sender, EventArgs e) { Shell32.ShellClass shell = new Shell32.ShellClass(); Shell32.Folder2 folder = (Shell32.Folder2)shell.BrowseForFolder( this.Handle.ToInt32(), // Window handle as type int "Select Folder...", // Window caption 0, // Option flags...the only part you'll have to hard-code values for if you want them Shell32.ShellSpecialFolderConstants.ssfDESKTOP // Optional root folder, default is Desktop ); if (folder == null) { return; } this.textBox1.Text = folder.Self.Path; outputDir = folder.Self.Path;; }
private void addSharedFolderButton_Click(object sender, System.EventArgs e) { Shell32.Shell shell = new Shell32.ShellClass(); Shell32.Folder folder = shell.BrowseForFolder(this.Handle.ToInt32(),"Select a directory to share. That directory and all sub-folders will also be made available on the network.",1,null); string directoryString = null; if (folder != null) { if (folder.ParentFolder != null) { for (int i = 0 ; i < folder.ParentFolder.Items().Count ; i++) { if (folder.ParentFolder.Items().Item(i).IsFolder) { if (((Shell32.Folder)(folder.ParentFolder.Items().Item(i).GetFolder)).Title == folder.Title) { directoryString = folder.ParentFolder.Items().Item(i).Path; break; } } } } if (directoryString == null || directoryString.StartsWith("::") == true) { MessageBox.Show(this,"Invalid folder","Output Folder",MessageBoxButtons.OK,MessageBoxIcon.Warning); directoryString = null; } } if (directoryString != null) { MediaServer.AddSharedFolder(directoryString); refreshSharedFolders(); } }