I have all the dirctories (2014, 2012), the files of each selected folder (.pdf) in the listbox 2
get the dirctories by this code ,
- if (FBD.ShowDialog() == DialogResult.OK)
- {
- listBox1.Items.Clear();
- DirectoryInfo[] diri_info =newDirectoryInfo(FBD.SelectedPath).GetDirectories();
- foreach (DirectoryInfo diri in diri_info)
- {
- listBox1.Items.Add(diri);
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (listBox1.SelectedIndex >= 0)
- {
- DirectoryInfo dirictory_choisis = (DirectoryInfo)listBox1.SelectedItem;
- FileInfo[] files = dirictory_choisis.GetFiles();
- listBox2.Items.Clear();
- foreach (FileInfo file in files)
- {
- listBox2.Items.Add(file);
- }
- }
- else
- {
- MessageBox.Show("selectioner un dossier");
- }
- }
Now how I can open the selected file (.pdf) ?
i use this code but dosn't work ( throw an exception file dosn't found)
- private void listBox2_Click(object sender, EventArgs e)
- {
- FileInfo file =(FileInfo) listBox2.SelectedItem;
- Process.Start(file.Name);
- }
Khaja MoizuddinPosted Jun 3, 2017, 8:09 PM