"there is no error messages. it is working but when i click on button, paths on the listview are opening automatically. I want to open these folders by clicking on their path on listview"
The files are opening "autotmatically" because you are executing:
Process.Start("explorer.exe", Path.GetDirectoryName(ext));
Take that line of code out, and write a handler for the ListView SelectedIndexChanged Event: in that EventHandler "do the right thing" to open the file(s) based on which ListViewItem(s) was/were clicked on.
To eliminate complex look-up of the filepath data that correspond to each ListViewItem's Value, I would use a Dictionary ... like this:
private Dictionary<listviewitem,> dctLVItemToString = new Dictionary<listviewitem,>();
for (int i = 0; i < 10; i++)
{
string iStr = i.ToString();
ListViewItem lvItem = new ListViewItem(iStr);
listView1.Items.Add(lvItem);
dctLVItemToString.Add(lvItem, "file " + iStr);
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
ListView.SelectedListViewItemCollection selectedItems = listView1.SelectedItems;
if (selectedItems.Count != 0)
{
string filePath = dctLVItemToString[selectedItems[0]];
MessageBox.Show(filePath);
}
}
The idea is to simplify, and speed-up, look-up.