用IO.Path类开取得目录就可以了
具体的查一下MSDN中的IO.Path的说明

解决方案 »

  1.   

    麻烦是OpenFileDialog 不选一个文件不返回, 但我的程序基本上是指向一个新的目录
      

  2.   

    搞掂, 再网上找到的, 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
    }