[英]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 现在在我的鼠标双击事件中我打开一个特定的文件和文件夹会打开该文件,但是当它打开目录时会弹出一个新窗口。我希望在listview控件中打开该目录...此方案a的代码是
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 现在我想用其他方式做到这一点,如果该路径是drectory然后去populatelistview方法其他明智的process.start但它现在工作任何想法我该怎么做
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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.