我想将树视图中的所选项目添加到listview。请帮助我摆脱这个......
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
PopulateListView(e.Node.Checked.ToString());
}
void PopulateListView(string path)
{
listView1.Clear();
DirectoryInfo di = new DirectoryInfo(path);
if (di.Exists)
{
foreach (DirectoryInfo d in di.GetDirectories())
{
listView1.Items.Add(new ListViewItem(d.Name));
}
foreach (FileInfo f in di.GetFiles())
{
listView1.Items.Add(new ListViewItem(f.Name));
}
}
}