Пример #1
0
 private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (listBox1.SelectedIndex != 0)
     {
         this.Text = listBox1.SelectedItem.ToString();
         FileAcces uj = new FileAcces(listBox1.SelectedItem.ToString());
         listBox1.Items.Clear();
         listBox1.Items.Add("/.../");
         try
         {
             foreach (object element in uj.backpath())
             {
                 listBox1.Items.Add(element);
             }
         }
         catch (NullReferenceException)
         {
             MessageBox.Show("Még nem tudok megnyitni Fájlokat!");
             comboBox1.SelectedIndex = 0;
         }
     }
     else
     {
         string parent = FileAcces.backparent(this.Text);
         this.Text = parent;
         listBox1.Items.Clear();
         listBox1.Items.Add("/.../");
         foreach (object element in Directory.GetFileSystemEntries(parent))
         {
             listBox1.Items.Add(element);
         }
     }
 }
        }  //this is for the drive letter change

        private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            try
            {
                if (listView1.Items.IndexOf(listView1.SelectedItems[0]) != 0)
                {
                    if (listView1.SelectedItems[0].SubItems[0].Text != "/.../")
                    {
                        if (listView1.SelectedItems[0].SubItems[1].Text == "DIR")
                        {
                            try
                            {
                                this.Text = listView1.SelectedItems[0].SubItems[4].Text;
                            }
                            catch (ArgumentOutOfRangeException)
                            {
                                PopulateList();
                            }
                            PopulateList();
                        }
                        else
                        {
                            RunApp(listView1.SelectedItems[0].SubItems[4].Text);
                        }
                    }
                    else
                    {
                        string parent = FileAcces.backparent(this.Text);
                        this.Text = parent;
                        PopulateList();
                    }
                }
                else
                {
                    string parent = FileAcces.backparent(this.Text);
                    this.Text = parent;
                    PopulateList();
                }
            }
            catch (ArgumentOutOfRangeException)
            {
                PopulateList();
            }
        } //this is for entering to a folder
        } //this is for entering to a folder

        private void listView1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(Keys.Enter))
            {
                if (listView1.Items.IndexOf(listView1.SelectedItems[0]) != 0)
                {
                    try
                    {
                        this.Text = listView1.SelectedItems[0].SubItems[4].Text;
                    }
                    catch (ArgumentOutOfRangeException)
                    {
                        PopulateList();
                    }
                    PopulateList();
                }
                else
                {
                    string parent = FileAcces.backparent(this.Text);
                    this.Text = parent;
                    PopulateList();
                }
            }
        }  //this is for using enter button