engineer41
engineer41

Reputation: 81

how to open listview window explorer in listview control

i have a listview window browser thats working completely fine .i open folder through folder browser and the files and folders in that particular directory opens in the listview via using

PopulateListView(path)

now in my mouse double click event im opening a particular file and folder it opens the file but when it opens the directory a new window pops up .i want that directory to b opened in the listview control...the code for this scenarioa is

private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            string pathdoubleClicked = listView1.FocusedItem.Tag.ToString();
          PopulateListView(pathdoubleClicked);

            Process.Start(pathdoubleClicked);
             simpleStack.Push(pathdoubleClicked);
        }

now i want to do it with if else like if the path is of drectory then go to populatelistview method other wise process.start but its now working any idea how can i do this

Upvotes: 0

Views: 947

Answers (1)

ken2k
ken2k

Reputation: 48985

From what I understand, if the path is a directory, you want to display its content on double-click. If it's a file, you want to open it.

So you would simply do:

private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
{
    string pathdoubleClicked = listView1.FocusedItem.Tag.ToString();

    if (System.IO.Directory.Exists(pathdoubleClicked))
    {
        PopulateListView(pathdoubleClicked);
    }
    else
    {
        Process.Start(pathdoubleClicked);
    }

    // ?
    simpleStack.Push(pathdoubleClicked);
}

Upvotes: 1

Related Questions