Пример #1
0
    public void OpenFile()
    {
        OpenFileBrowse pth = new OpenFileBrowse();

        pth.structSize = System.Runtime.InteropServices.Marshal.SizeOf(pth);
        //pth.filter = "txt files(.txt)|.txt";
        pth.file         = new string(new char[256]);
        pth.maxFile      = pth.file.Length;
        pth.fileTitle    = new string(new char[64]);
        pth.maxFileTitle = pth.fileTitle.Length;
        pth.initialDir   = Application.dataPath; // default path
        pth.title        = "打开项目";
        pth.defExt       = "txt";
        pth.flags        = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;
        //0x00080000   是否使用新版文件选择窗口
        //0x00000200   是否可以多选文件
        if (OpenFileDialog.GetOpenFileName(pth))
        {
            string filepath = pth.file;//选择的文件路径;
            MenuButton.path = filepath;

            string text = File.ReadAllText(@filepath);

            inputText.text = text;
        }
    }
Пример #2
0
 public static extern bool GetOpenFileName([In, Out] OpenFileBrowse ofd);