public static string BrowseForFolder(string title, System.Windows.Forms.Form owner) { ShBrowseInfo bi = new ShBrowseInfo(); StringBuilder buffer = new StringBuilder(MAX_PATH); bi.hOwner = owner.Handle.ToInt32(); bi.pidlRoot = 0; bi.lpszTitle = title; bi.ulFlags = BIF_RETURNONLYFSDIRS; int pidl = SHBrowseForFolderA(ref bi); SHGetPathFromIDListA(pidl, buffer); CoTaskMemFree(pidl); return(buffer.ToString()); }
private static extern int SHBrowseForFolderA(ref ShBrowseInfo lpBrowseInfo);