C#: how to check and display the content of a folder?

Posted by user147685 on Stack Overflow See other posts from Stack Overflow or by user147685
Published on 2009-09-16T06:50:08Z Indexed on 2010/03/29 19:43 UTC
Read the original article Hit count: 284

Filed under:

I'm not sure whether this topics has been disscussed before or not, but I'm not sure the exact word to search for it. What method/class should I use?

The program has 3 buttons: 1) for folder browsing, 2) scan for the selected folder content, and 3) open the file. When user browse the selected folder*(1), user click scan button to scan from the first file until the last available files and listed it text box(2)* and from that user can decide whether to open the files or not*(3)*.

Here are what have I done so far (no 1 and 3):

//For browse.
private void browse2()
{
    if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
     {
        this.txtDest.Text = folderBrowserDialog1.SelectedPath;
     }
}

//For opening folder.
private void btnOpen_Click(object sender, EventArgs e)
{
    try
    {
        Process.Start(txtDest.Text);
    }
    catch
    {
        MessageBox.Show("Please select one file/folder");
    }
}

© Stack Overflow or respective owner

Related posts about c#