Unity调用windows系统dialog 选择文件夹
#region 调用windows系统dialog 选择文件夹
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public class OpenDialogFile
{
public int structSize = 0;
public IntPtr dlgOwner = IntPtr.Zero;
public IntPtr instance = IntPtr.Zero;
public String filter = null;
public String customFilter = null;
public int maxCustFilter = 0;
public int filterIndex = 0;
public String file = null;
public int maxFile = 0;
public String fileTitle = null;
public int maxFileTitle = 0;
public String initialDir = null;
public String title = null;
public int flags = 0;
public short fileOffset = 0;
public short fileExtension = 0;
public String defExt = null;
public IntPtr custData = IntPtr.Zero;
public IntPtr hook = IntPtr.Zero;
public String templateName = null;
public IntPtr reservedPtr = IntPtr.Zero;
public int reservedInt = 0;
public int flagsEx = 0;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public class OpenDialogDir
{
public IntPtr hwndOwner = IntPtr.Zero;
public IntPtr pidlRoot = IntPtr.Zero;
public String pszDisplayName = null;
public String lpszTitle = null;
public UInt32 ulFlags = 0;
public IntPtr lpfn = IntPtr.Zero;
public IntPtr lParam = IntPtr.Zero;
public int iImage = 0;
}
public class DllOpenFileDialog
{
[DllImport("Comdlg32.dll", SetLastError = true, ThrowOnUnmappableChar = true, CharSet = CharSet.Auto)]
public static extern bool GetOpenFileName([In, Out] OpenDialogFile ofn);
[DllImport("Comdlg32.dll", SetLastError = true, ThrowOnUnmappableChar = true, CharSet = CharSet.Auto)]
public static extern bool GetSaveFileName([In, Out] OpenDialogFile ofn);
[DllImport("shell32.dll", SetLastError = true, ThrowOnUnmappableChar = true, CharSet = CharSet.Auto)]
public static extern IntPtr SHBrowseForFolder([In, Out] OpenDialogDir ofn);
[DllImport("shell32.dll", SetLastError = true, ThrowOnUnmappableChar = true, CharSet = CharSet.Auto)]
public static extern bool SHGetPathFromIDList([In] IntPtr pidl, [In, Out] char[] fileName);
}
public string OpenWindowsDialog()
{
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'));
return fullDirPath;//这个就是选择的目录路径。
}
#endregion
Unity调用windows系统dialog 选择文件夹的更多相关文章
- Unity调用Windows窗口句柄,选择文件和目录
T:2019-6-25 10:06:59 C:Scatt Kang using System; using System.Collections; using System.Collections.G ...
- Delphi 弹出Windows风格的选择文件夹对话框, 还可以新建文件夹
Delphi 弹出Windows风格的选择文件夹对话框, 还可以新建文件夹 unit Unit2; interface uses Windows, Messages, SysUtils, V ...
- C# 选择文件、选择文件夹、打开文件(或者文件夹) 路径中获取文件全路径、目录、扩展名、文件名称 追加、拷贝、删除、移动文件、创建目录 修改文件名、文件夹名!!
https://www.cnblogs.com/zhlziliaoku/p/5241097.html 1.选择文件用OpenDialog OpenFileDialog dialog = new Ope ...
- C#选择文件、选择文件夹、打开文件(或者文件夹)
1.选择文件用OpenDialog OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = true;//该值确定是否可以 ...
- C#选择文件、选择文件夹、打开文件
1.选择文件用OpenDialog OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = true;//该值确定是否可以 ...
- WPF中选择文件和选择文件夹的方法
最近从winform转WPF,遇到了各种各样的问题.然而网上的关于WPF的资料少之又少,甚至连基本的文件选择操作,百度搜索的首页都没有一个比较好的方法.所以,踩了几个坑之后,我把我得到的方法分享给大家 ...
- FTP文件夹打开错误,Windows无法访问此文件夹
错误提示: Windows 无法访问此文件夹,请确保输入的文件夹是正确的,并且你有权访问此文件夹. 解决方法/步骤如下 1.请确保输入的文件夹是正确的,并且你有权访问此文件夹.可以在浏览器 ...
- 使用C#选择文件夹、打开文件夹、选择文件
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- Windows下如何将一个文件夹通过Git上传到GitHub上(转)
在通过windows系统的电脑上写代码,需要将项目上传到GitHub上去.比如在Pycharm上写Django后端,整个项目是一个文件夹的形式,那么怎么才能这个文件夹通过Git命令上传到GitHub上 ...
随机推荐
- 云顶之弈换中立python脚本
import pynput keyboard = pynput.keyboard.Controller() mouse = pynput.mouse.Controller() def on_relea ...
- GSOAP服务卡住?
很久以前参考了https://www.genivia.com/doc/soapdoc2.html 中的一段: How to Create a Multi-Threaded Stand-Alone Se ...
- [linux] 多进程和多线程
1.在Linux系统下,启动一个新的进程必须分配给它独立的地址空间,建立众多的数据表来维护它的代码段.堆栈段和数据段,这是一种”昂贵”的多任务工作方式.2.而运行于一个进程中的多个线程,它们彼此之间使 ...
- lua 的 cjson 安装,使用
1. 背景: 虚拟机安装的luajit 没有 cjson 库,就不能对 table 进行 编码操作,手动安装一个. 2. 安装: cjson下载地址:http://www.kyne.com.au/~ ...
- Linux安装php-mysql提示需要:libmysqlclient.so.18()(64bit)的解决办法
Linux安装php-mysql提示需要:libmysqlclient.so.18()(64bit)的解决办法 在LNMP编译环境下安装zabbix会出现 执行:yum -y install net- ...
- Jmeter接口测试,变量是订单和订单明细,怎么一起传?
", "price": 12.0, "orderDate": "2019-07-05 10:40:00", "order ...
- git仓库的安装和基本使用
一.安装git软件 # yum install git -y 二.初始化git仓库 2.1 在git仓库的机器进行配置 # ifconfig eth0 | awk -F '[ :]+' 'NR==2 ...
- Dart Flutter
下载Flutter Google下载地址: https://storage.googleapis.com/dart-archive/channels/stable/release/2.3.0/sdk/ ...
- 为何JAVAWEB绝对路径访问不了图片
为何JAVAWEB绝对路径访问不了图片?其实这涉及到两个原因 1:浏览器类型不同: 五大主流浏览器内核有所不同,能够支持的功能不一样:如谷歌浏览器就不能查看绝对路径 2:涉及到保护隐私安全: (谷歌浏 ...
- java web问题总结
1.java web上传附图页面空,无返回 原因:前端页面与后台端口不一致,无页面可返回 2.上传excel导入数据时,只能导入第一条,后面的数据无法导入,缓存设置过小.