Quantcast
Channel: Questions in topic: "build"
Viewing all articles
Browse latest Browse all 4084

Can't save csv file from an exe build

$
0
0
I'm creating a piece of a sample game about a rocket following a plane, and then saving the path that the plane took to a csv file along with the rocket one. When I run the code at unity editor, the file is saved as required to Assets/csv, as declared in the code, and when I run it into build, it should be saved to the same directory as the exe files, but it turns out that the file isn't saved. Here's the function I'm using for saving the file: public void saveResults() { string delimiter = ","; delimiter = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator; StringBuilder sb = new StringBuilder(); int length = list.Count; Debug.Log ("length of list: " + length); for (int index = 0; index < length; index++) { sb.AppendLine(string.Join(delimiter, list[index])); } string filePath = getPath(); Debug.Log (filePath); StreamWriter outStream = new StreamWriter(filePath, true); outStream.WriteLine(sb); outStream.Close(); } And here's how I return the path required depend on platform: private string getPath() { string filename = DateTime.Now.ToString("dd-MM-yyyy-HHmmss"); if (Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.WindowsPlayer) { return Application.dataPath + "/csv/" + filename + ".csv"; } else if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.WindowsEditor) { return Application.dataPath + "/"+ filename + ".csv"; } } Can anyone give me a hand how to save the file, I've tried it on mac and windows and both are the same case. Thanks

Viewing all articles
Browse latest Browse all 4084

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>