Unity C# 打开windows对话框选择文件夹或选择文件

编程入门 行业动态 更新时间:2024-10-21 18:57:20

Unity C# 打开windows<a href=https://www.elefans.com/category/jswz/34/1761322.html style=对话框选择文件夹或选择文件"/>

Unity C# 打开windows对话框选择文件夹或选择文件

unity没有提供打开windows对话框的api,在开发种也会遇到选择系统文件夹或选择系统文件的需求

///
/工具:windows系统文件夹/文件选择窗口//
///
using System;
using System.Runtime.InteropServices;
public class OpenFile
{/// <summary>/// 选择文件夹/// </summary>public static string ChooseWinFolder(){//使用如下:OpenDialogDir ofn = new OpenDialogDir();ofn.pszDisplayName = new string(new char[2000]); ;     // 存放目录路径缓冲区  ofn.title = "选择文件夹";// 标题  //ofn.ulFlags = BIF_NEWDIALOGSTYLE | BIF_EDITBOX; // 新的样式,带编辑框  IntPtr pidlPtr = WindowDll.SHBrowseForFolder(ofn);char[] charArray = new char[2000];for (int i = 0; i < 2000; i++)charArray[i] = '\0';WindowDll.SHGetPathFromIDList(pidlPtr, charArray);string fullDirPath = new String(charArray);

更多推荐

Unity C# 打开windows对话框选择文件夹或选择文件

本文发布于:2023-11-14 14:30:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587705.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对话框   文件夹   文件   Unity   windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!