Exemple #1
0
        public void SelectFolder(GameObject obj)
        {
            OpenDialogDir ofn2 = new OpenDialogDir();

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

            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'));
            if (fullDirPath != "")
            {
                fullDirPath     += "\\";
                TargetFolderPath = fullDirPath;

                dicMEconfigLive["Out_Put_Path"] = TargetFolderPath;

                AppConfig.SaveConfigFile(Application.streamingAssetsPath + "/" + MEHoloConstant.LiveConfigFile, dicMEconfigLive);
            }
        }
    public void OnChooseClick()
    {
        OpenDialogDir ofn2 = new OpenDialogDir();

        ofn2.pszDisplayName = new string(new char[2000]);;     // 存放目录路径缓冲区  
                ofn2.lpszTitle = "打开文件夹";                      // 标题  
                                                               //ofn2.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX; // 新的样式,带编辑框  
                IntPtr pidlPtr = DllOpenFileDialog.SHBrowseForFolder(ofn2);

        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'));
        inputText.text = fullDirPath;

        choosePath = fullDirPath;
    }
            public static string FolderBrowserDlg(string defaultPath = "")
            {
                OpenDlgDir dlg = new OpenDlgDir();

                dlg.pszDisplayName = defaultPath;
                dlg.ulFlags        = BIF_USENEWUI;
                //设置hwndOwner==0时,是非模态对话框,设置hwndOwner!=0时为模态对话框
                dlg.hwndOwner = DllOpenFileDialog.GetForegroundWindow();

                IntPtr pidlPtr = DllOpenFileDialog.SHBrowseForFolder(dlg);

                char[] charArray = new char[MAX_PATH_LENGTH];
                DllOpenFileDialog.SHGetPathFromIDList(pidlPtr, charArray);
                string foldPath = new String(charArray);

                foldPath = foldPath.Substring(0, foldPath.IndexOf('\0'));
                return(foldPath);
            }
    private string OpenPath()
    {
        OpenDialogDir ofn2 = new OpenDialogDir();

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

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

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

        return(path);
    }
    public string OpenDir()
    {
        OpenDialogDir dir = new OpenDialogDir();

        dir.pszDisplayName = new string(new char[2000]);;
        dir.lpszTitle      = "选择播放目录";
        IntPtr pidlPtr = DllOpenFileDialog.SHBrowseForFolder(dir);

        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);
    }
Exemple #6
0
        static public string GetDirPathByDialog(string title)
        {
            OpenDialogDir odd = new GKFileUtil.OpenDialogDir();

            odd.pszDisplayName = new string(new char[1000]);
            odd.lpszTitle      = title;
            //ofn2.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX;
            IntPtr pidlPtr = DllOpenFileDialog.SHBrowseForFolder(odd);

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

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

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

            return(fullDirPath);
        }
    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);
    }
Exemple #8
0
    public static void OpenFilesPath(out string exportPath)
    {
        OpenDialogDir ofn2 = new OpenDialogDir();

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

        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'));

        Debug.Log(fullDirPath);//这个就是选择的目录路径。

        exportPath = fullDirPath;
    }
    /// <summary>
    /// 弹窗选择文件夹
    /// </summary>
    /// <returns></returns>
    public string getFilePath()
    {
        OpenDialogDir ofn2 = new OpenDialogDir();

        ofn2.pszDisplayName = new string(new char[2000]);; // 存放目录路径缓冲区
        ofn2.lpszTitle      = "Open Folder";               // 标题
                                                           //ofn2.ulFlags = ofn2.BIF_EDITBOX; 崩溃


        IntPtr pidlPtr = DllOpenFileDialog.SHBrowseForFolder(ofn2);

        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);
    }