I added these three components from tools menu/choose toolbox items; however they are not working when I changed the drive or directory..

here is the code of these three components in case they change

    private void driveListBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            dirListBox1.Path = driveListBox1.Drive;
        }
        catch (Exception ex)
        {
            MessageBox.Show("Error : " + ex.Message,
                            "Error",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
        }
    }

    private void dirListBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            this.fileListBox1.Path = this.dirListBox1.Path;
        }
        catch (Exception ex)
        {
            MessageBox.Show("Error : " + ex.Message,
                            "Error",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
        }
    }

    private void fileListBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string fullPath = fileListBox1.Path + "\\" + fileListBox1.FileName;
        try
        {
            StreamReader sr = new StreamReader(fullPath);
            textBox2.Text = sr.ReadToEnd();
            textBox1.Text = fullPath;
        }
        catch (Exception ex)
        {
            MessageBox.Show("Error : " + ex.Message,
            "Error",
            MessageBoxButtons.OK,
            MessageBoxIcon.Error);
        }
    }

it is said that these components are compatible wth VB.NET, does it mean I can't use them in a C# project?

I tried them out in 2008, and the directory browser's path does not react correctly. You can add some text boxes to your form that are populated with the new path from this component as you select or even double click around on the dir component... It fails 90% of the time to update it own Path property.
I would look for an alternative solution.

// Jerry

I have used openfiledialog class instead of the components above and it works fine now.. anyway thanx for the reply jerry..

hi - just do .Refresh() after setting the Path. seems to work fine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.