public static string SaveFile(string title, string filter) { var projectFolder = Directory.GetCurrentDirectory(); FileDialogBase pth = new FileDialogBase(); pth.structSize = System.Runtime.InteropServices.Marshal.SizeOf(pth); pth.filter = filter; pth.file = new string(new char[256]); pth.maxFile = pth.file.Length; pth.fileTitle = new string(new char[64]); pth.maxFileTitle = pth.fileTitle.Length; #if Debug pth.initialDir = Application.streamingAssetsPath.Replace('/', '\\') + "\\MyStages\\"; // default path #else pth.initialDir = Application.dataPath.Replace('/', '\\') + "\\"; // default path #endif pth.title = title; pth.defExt = "txt"; pth.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008; string filePath = null; if (SaveFileDialog.GetSaveFileName(pth)) { filePath = pth.file;//选择的文件路径; } Directory.SetCurrentDirectory(projectFolder); return(filePath); }
public static extern bool GetSaveFileName([In, Out] FileDialogBase ofd);