コード例 #1
0
    public static string OpenDir(string title = "选择")
    {
        DialogDir open = new DialogDir();

        // 存放目录路径缓冲区
        open.pszDisplayName = new string(new char[2000]);
        open.lpszTitle      = title;
                //open.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX; // 新的样式,带编辑框  
                IntPtr pidlPtr = DllOpenFileDialog.SHBrowseForFolder(open);

        char[] charArray = new char[2000];
        for (int i = 0; i < 2000; i++)
        {
            charArray[i] = '\0';
        }

        DllOpenFileDialog.SHGetPathFromIDList(pidlPtr, charArray);
        string fullDirPath = new String(charArray);

        fullDirPath = fullDirPath.Substring(0, fullDirPath.IndexOf('\0'));

        return(fullDirPath);
    }
コード例 #2
0
 public static extern IntPtr SHBrowseForFolder([In, Out] DialogDir ofn);