0
\$\begingroup\$

It seems many people do this with regards to game data so they recommend userprefs, but I just want the user to have the file in the end, whether this is the Files app on iOS or choosing a folder to save in on Android or even just attaching the file as an attachment to an email that they can send using their preferred mail app or something.

\$\endgroup\$
1
\$\begingroup\$

I used native share since Unity doesn't really provide this feature.

Saving the csv was also very straightforward:

public string save()
{
    string fileName = Application.persistentDataPath + "/saveDefault.csv";
    using (StreamWriter w = new StreamWriter(fileName, false))
    {
        foreach (TrafficRecord tr in data)
        {
            string line = string.Format(
                "{0},{1},{2}",
                tr.entryTime.ToString("MM/dd/yyyy hh:mm:ss tt"),
                tr.vehicleType.ToString(),
                tr.direction.ToString()
            );
            w.WriteLine(line);
            w.Flush();
        }
    }
    Debug.Log("Savefile saved to: " + fileName);
    return fileName;
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.