public void ChooseFolder(bool IN) { //选择文件路径 OpenDialogDir openFile = new OpenDialogDir(); openFile.pszDisplayName = new string(new char[2000]); openFile.lpszTitle = "选择视频文件夹"; IntPtr pidIPtr = LocalDialog.SHBrowseForFolder(openFile); char[] charArray = new char[2000]; for (int i = 0; i < 2000; i++) { charArray[i] = '\0'; } LocalDialog.SHGetPathFromIDList(pidIPtr, charArray); string fullDirPath = new string(charArray); fullDirPath = fullDirPath.Substring(0, fullDirPath.IndexOf('\0')); Debug.Log(fullDirPath); InNote.text = "视频格式为:"; Start.text = "开始批量转换"; Save.text = "输出至"; isPNG.SetActive(false); inin.transform.localPosition = new Vector3(231, inin.transform.localPosition.y, inin.transform.localPosition.z); if (IN) { ShellManager.inUrl = fullDirPath; sm.ChooseFolderAgument(true); } else { ShellManager.outUrl = fullDirPath; } }
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); } }
/// <summary> /// 调用WindowsExploer 并返回所选文件夹路径 /// </summary> /// <param name="dialogtitle">打开对话框的标题</param> /// <returns>所选文件夹路径</returns> public static string GetPathFromWindowsExplorer(string dialogtitle = "请选择下载路径") { string res; OpenDialogDir ofn2 = new OpenDialogDir(); // 存放目录路径缓冲区 ofn2.pszDisplayName = new string(new char[2000]); ofn2.pidlRoot = ILCreateFromPathW(Application.dataPath.Replace('/', '\\')); // 标题 ofn2.lpszTitle = dialogtitle; // 新的样式,带编辑框 ofn2.ulFlags = BIF_NEWDIALOGSTYLE; IntPtr pidlPtr = WindowsExplorer.SHBrowseForFolder(ofn2); char[] charArray = new char[2000]; for (int i = 0; i < 2000; i++) { charArray[i] = '\0'; } WindowsExplorer.SHGetPathFromIDList(pidlPtr, charArray); res = new String(charArray); res = res.Substring(0, res.IndexOf('\0')); return(res); }
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 OpenResourceFolder() { OpenDialogDir openDialogDir = new OpenDialogDir(); openDialogDir.pszDisplayName = new string(new char[2000]); openDialogDir.lpszTitle = "Open Project"; IntPtr pidlPtr = SHBrowseForFolder(openDialogDir); char[] charArray = new char[2000]; Array.Fill(charArray, '\0'); SHGetPathFromIDList(pidlPtr, charArray); int length = Array.IndexOf(charArray, '\0'); string fullDirPath = new String(charArray, 0, length); return(fullDirPath); }
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); }
/* * 打开选择文件夹窗口 * 参数: * cb:选择文件后的回调 * folderName:窗口名 */ public static void SelectDir(GetDirCallBack cb, string folderName = "窗口标题") { OpenDialogDir ofn2 = new OpenDialogDir(); ofn2.pszDisplayName = new string(new char[2000]);; // 存放目录路径缓冲区 ofn2.lpszTitle = folderName; // 标题 //ofn2.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX; // 新的样式,带编辑框 IntPtr pidlPtr = LocalDialog.SHBrowseForFolder(ofn2); char[] charArray = new char[2000]; for (int i = 0; i < 2000; i++) { charArray[i] = '\0'; } LocalDialog.SHGetPathFromIDList(pidlPtr, charArray); string fullDirPath = new String(charArray); fullDirPath = fullDirPath.Trim('\0'); OpenFileName openFileName = new OpenFileName(); openFileName.file = fullDirPath; cb(openFileName); }
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); }
internal static extern IntPtr SHBrowseForFolder([In, Out] OpenDialogDir ofn);
public void FindFileDir(int value) { if (checkDataError()) { return; } Text tt = null; OpenDialogDir ofn2 = new OpenDialogDir(); ofn2.pszDisplayName = new string(new char[2000]);; // 存放目录路径缓冲区 switch (value) { case 1: ofn2.dirTitle = "设置源目录"; tt = gameObject.transform.Find("BaseDirText").GetComponent <Text>(); break; case 2: ofn2.dirTitle = "设置目标目录"; tt = gameObject.transform.Find("TargetDirText").GetComponent <Text>(); break; case 3: ofn2.dirTitle = "设置索引目录"; tt = gameObject.transform.Find("LogText").GetComponent <Text>(); break; } //ofn2.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX; // 新的样式,带编辑框 IntPtr pidlPtr = DllBox.SHBrowseForFolder(ofn2); char[] charArray = new char[2000]; for (int i = 0; i < 2000; i++) { charArray[i] = '\0'; } DllBox.SHGetPathFromIDList(pidlPtr, charArray); string fullDirPath = new String(charArray); fullDirPath = fullDirPath.Substring(0, fullDirPath.IndexOf('\0')); Debug.Log(fullDirPath);//这个就是选择的目录路径。 if (tt == null) { return; } tt.text = fullDirPath; //for (int i = 20; i < tt.text.Length; i += 20) // tt.text = tt.text.Insert(i, "\n"); if (value == 1) { data.BaseDirPath = fullDirPath; } else if (value == 2) { data.TargetDirPath = fullDirPath; } else if (value == 3) { data.FolderPath = fullDirPath; } }