的FolderBrowserDialog SelectedPath与重新分析点 [英] FolderBrowserDialog SelectedPath with reparse points
问题描述
我在用的FolderBrowserDialog的SelectedPath财产问题时,我选择的文件夹是一个远程服务器上,是一个符号链接(或任何形式的重新分析点)。
I'm having issues with the SelectedPath property of the FolderBrowserDialog when the folder I select is on a remote server and is a symbolic link (or any kind of reparse point).
如果我选择一个正常的文件夹,然后我得到的完整路径返回,例如\服务器\文件夹\子文件夹\ thing_I_clicked_on。
If i select a normal folder, then I get the full path returned, for example "\SERVER\folder\subfolder\thing_I_clicked_on".
不过,如果该文件夹是重分析点,我得到的只是\ SERVER \ thing_I_clicked_on(所以它缺少完整路径)
However, if the folder is a reparse point, i get just "\SERVER\thing_I_clicked_on" (so it's missing the full path)
var dialog = new FolderBrowserDialog();
dialog.ShowDialog();
MessageBox.Show(dialog.SelectedPath);
任何人遇到这样或有什么建议?它似乎并没有被相关权限,因为如果我知道的完整路径,我可以很愉快地浏览到它,等等。
Anyone come across this or have any suggestions? It doesn't appear to be permissions related, as if I know the full path i can quite happily browse to it, etc.
推荐答案
所以,我一直在调查这颇多,并认为我有一个答案。
so, I've been investigating this quite a lot, and think i have an answer.
首先,稍微解释一下什么我看到的!
First, a bit of explanation about what I was seeing!
在服务器A上,还有它包含到一个共享的符号链接服务器B上的共享:
on server A, there is a share which contains a symbolic link to a share on server B:
\\serverA\Path\To\Folder
和的该目标是
\\serverB\Folder
什么是实际发生的事情是,从返回的值 FolderBrowserDialog.SelectedPath
是 \\ SERVERB \文件夹
,和我错误地认为这是缺少路径的部分,因为琴弦serverA的和ServerB都非常相似!对不起,误导大家。
What was actually happening was, the value returned from FolderBrowserDialog.SelectedPath
was \\serverB\Folder
, and I was mistakenly thinking it was missing parts of the path, because the strings serverA and serverB are very similar! Sorry for misleading everyone.
我下面这个 MSDN示例<创建了自己的包装/一>,并注意到的Shell32.dll功能 SHGetPathFromIDList
将退回重新分析点的目标,尽管该文件说
I created my own wrapper following this MSDN Example and noticed that the Shell32.dll function SHGetPathFromIDList
is returning the Target of the reparse point, despite the fact that the documentation says
如果该PIDL参数指定一个快捷方式,pszPath将包含 该路径的快捷方式,而不是快捷方式的目标。
If the pidl parameter specifies a shortcut, the pszPath will contain the path to the shortcut, not to the shortcut's target
我也注意到,在这之前的路径是正确的了,所以在我的回调方法,当状态改变时,我抓住了翻译选择的路径
I did notice that the path before that is the correct one though, so in my callback method when the status changed, I captured the untranslated selected path
private int FolderBrowserCallback(IntPtr hwnd, int msg, IntPtr lParam, IntPtr lpData)
{
switch (msg)
{
case BrowseForFolderMessages.BffmSelchanged:
if (haveValidPath && !String.IsNullOrEmpty(displayedPath))
{
if (IntPtr.Zero != _hwndEdit)
{
SelectedFullPath = displayedPath;
}
}
因此, SelectedFullPath
属性包含 \\ serverA的\路径\为\文件夹
和 SelectedPath
属性包含 \\服务器B \文件夹
,这给我留下了很多的工作。
So the SelectedFullPath
Property contains \\serverA\Path\To\Folder
and SelectedPath
property contains \\ServerB\Folder
, which leaves me a lot to work with.
这篇关于的FolderBrowserDialog SelectedPath与重新分析点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!