如何设置现有的Explorer.exe实例来选择一个文件? [英] How can I set an existing Explorer.exe instance to select a file?

查看:180
本文介绍了如何设置现有的Explorer.exe实例来选择一个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以轻松地获得资源管理器打开和使用下列选择一个文件:

I can easily get Explorer to open up and select a file using the following :

string argument = @"/select, " + filePath;
System.Diagnostics.Process.Start("explorer.exe", argument);



然而,当我以开放来的下一个文件,我会得到Explorer的一个新实例。这可能会导致我们的用户打开含有几百个探险家通过密集的一天结束开放的。

However when I come to opening up the next file, I will get a new instance of explorer. This could result in our users opening having hundreds of explorers open by the end of an intensive day.

我怎样才能得到它重用一个已经打开资源管理器实例选择文件我想要什么?

How can I get it to reuse an already open explorer instance to select the file I want?

Visual Studio中能做到这一点,当你在选项卡上单击右键,选择的包含打开文件夹... 的探险家提供已在同一个目录中打开。它是如何能做到这一点?

Visual Studio can do this when you right click on a tab and select Open containing folder... providing explorer is already opened at the same directory. How has it been able to do this?

推荐答案

怎么样的通过使用嵌入浏览器窗口到你的应用中的 ExplorerBrowser 对象?这样,你可以只保留重用窗口通过调用 IExplorerBrowser :: BrowseToObject 上,当你想显示不同的文件夹不同的文件夹。

How about embedding the Explorer window into your application by using the ExplorerBrowser object? That way, you can just keep reusing the window by calling IExplorerBrowser::BrowseToObject on a different folder when you want to show a different folder.

试图renavigate现有的资源管理器窗口有问题,因为你不知道什么用户做了与该窗口,而你都没有注意。也许他们使用的文件夹窗格中去一些其他的文件夹,然后的热潮的你刚才撕开该文件夹了,从下他们送到别处。或者,也许他们关闭它!打开一个新的浏览器窗口是事物的发射后不管的类型。如果您想保留窗口的控制,那么你需要锻炼更明确的控制(例如,通过 ExplorerBrowser 以上)。

Trying to renavigate an existing Explorer window is problematic because you don't know what the user did with that window while you weren't looking. Maybe they used the Folder pane to go to some other folder, and then boom you just ripped that folder out from under them and sent it somewhere else. Or maybe they closed it! Opening a new Explorer window is a fire-and-forget type of thing. If you want to retain control of the window, then you need to exercise more explicit control (e.g. via ExplorerBrowser above).

这篇关于如何设置现有的Explorer.exe实例来选择一个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆