public string SaveFile() { SaveFileBrowse pth = new SaveFileBrowse(); 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; if (SaveFileDialog.GetSaveFileName(pth)) { string filepath = pth.file;//选择的文件路径; File.WriteAllText(filepath, inputText.text); return(filepath); } return("NullPath"); }
public static extern bool GetSaveFileName([In, Out] SaveFileBrowse ofd);