protected void OnDisplayButtonClick(object sender, EventArgs e) { try { string folderPath = InputTextBox.Text; var theFolder = new DirectoryInfo(folderPath); if (theFolder.Exists) { DisplayFolderList(theFolder.FullName); return; } var theFile = new FileInfo(folderPath); if (theFile.Exists) { if (theFile.Directory != null) { DisplayFolderList(theFile.Directory.FullName); } int index = FilesListBox.Items.IndexOf(theFile.Name); FilesListBox.SetSelected(index, true); return; } throw new FileNotFoundException(string.Format("There is no file or folder with this name: {0}", InputTextBox.Text)); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public OpenRecentForm(string[] files) { InitializeComponent(); for (int i = 0; i < files.Length; i++) { FilesListBox.Items.Add(files[i]); } FilesListBox.SetSelected(0, true); }
private void FilesListBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { Form1 MainForm = (Form1)this.Owner; foreach (string item in FilesListBox.SelectedItems) { MainForm.addToList(item, drive.FileListID[FilesListBox.Items.IndexOf(item)], itemType); } } else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.A) { for (int i = 0; i < FilesListBox.Items.Count; i++) { FilesListBox.SetSelected(i, true); } } else if (e.KeyCode == Keys.F5) { PopulateListBoxes(drive, drive.currentFolder, true); } e.SuppressKeyPress = true; }