搞掂, 再网上找到的, import shell32string folderToReturn = null; try { Shell32.Shell shell = new Shell32.Shell (); Shell32.Folder folder = shell.BrowseForFolder(this.Handle.ToInt32(), "Select a folder", 8, ""); Shell32.FolderItems folderItems = folder.Items(); Shell32.FolderItem folderItem = folderItems.Item(0); String fullPath = folderItem.Path; // Now parse out the unecessary final part fullPath = fullPath.Substring(0, fullPath.LastIndexOf(@"\")); folderToReturn = fullPath; }catch { // An error occured. Just igonre it, null will be returned - we called a silly DLL anyway }
try {
Shell32.Shell shell = new Shell32.Shell ();
Shell32.Folder folder = shell.BrowseForFolder(this.Handle.ToInt32(), "Select a folder", 8, "");
Shell32.FolderItems folderItems = folder.Items();
Shell32.FolderItem folderItem = folderItems.Item(0);
String fullPath = folderItem.Path;
// Now parse out the unecessary final part
fullPath = fullPath.Substring(0, fullPath.LastIndexOf(@"\"));
folderToReturn = fullPath;
}catch {
// An error occured. Just igonre it, null will be returned - we called a silly DLL anyway
}