【发布时间】:2019-05-20 02:49:10
【问题描述】:
我正在尝试将文件从一个路径移动到另一个路径,目标路径需要支持便携式设备,例如 android 手机。
在发现FolderBrowserDialog 不支持便携式设备后,我发现this 博客解释了如何使用Shell32 和COM-Objects。
问题是我需要存储路径(字符串)并将其加载回(从文件)作为Folder 对象,这样做的方法是使用shell 方法shell.NameSpace(path)。
这仅适用于系统路径,否则它将返回 null:
shell = new Shell();
Folder folder = shell.BrowseForFolder((int) Handle, "Select folder", 0, 0);
Folder folderFromPath = shell.NameSpace((folder as Folder3).Self.Path);
//folderFromPath is null if I choose android device folder.
虽然这有效:
Folder folderFromPath = shell.NameSpace("C:\\Program Files");
//folderFromPath is not null
还有其他方法吗?
【问题讨论】: