private void Save(MicrogridVar[] mVars = null) { string text = MGMisc.MicrogridVarsToString(microgrid, mVars); try { File.WriteAllText(csvSaveFilePath, text); } catch (Exception e) { if (IsHandleableFileException(e)) { SendErrorMessage(e.Message); } else { throw; } } }
public void SaveDialog(MicrogridVar[] mVars) { #if !UNITY_WEBGL || UNITY_EDITOR var path = StandaloneFileBrowser.SaveFilePanel( saveTitle, GetSaveInitialPath(), defaultFileName, SaveExtension); if (path.Length > 0) { csvSaveFilePath = path; csvSaveDirectoryPath = Path.GetDirectoryName(path); Save(mVars); } #else string text = MGMisc.MicrogridVarsToString(microgrid, mVars); var bytes = Encoding.UTF8.GetBytes(text); DownloadFile(gameObject.name, "OnFileDownload", "outpso.csv", bytes, bytes.Length); #endif }