我需要在 Windows 资源管理器中获取当前选择的文件或文件夹的路径来放置ListView
. 我不知道怎么办希望你能帮忙。谢谢
更新源
public void GetListFileAndFolderOfWindowsExploer()
{
try
{
string fileName;
ArrayList selected = new ArrayList();
Shell32.Shell shell = new Shell32.Shell();
foreach (SHDocVw.InternetExplorer windows in new SHDocVw.ShellWindows())
{
fileName = Path.GetFileNameWithoutExtension(windows.FullName).ToLower();
if (fileName.ToLowerInvariant() == "explorer")
{
Shell32.FolderItems items = ((Shell32.IShellFolderViewDual2)windows.Document).SelectedItems();
foreach (Shell32.FolderItem item in items)
{
lift = new string[] { item.Name, item.Path };
ListViewItem list = new ListViewItem();
list.Text = item.Name;
list.SubItems.Add(item.Path);
list.UseItemStyleForSubItems = true;
listView1.Items.Add(list);
}
}
}
}
catch (Exception ex)
{
writelog(ex.Message);
}
}