how to write text file to Resources?

I read many thread about this, but cant not solve. I try to write a csv file to resource (or may be in other folder in asset )
to begin i use this

        string filePath = "/Assets/Resource/TurretInfo3.csv";
        StreamWriter outStream = System.IO.File.CreateText(filePath);
        outStream.WriteLine(sb);
        outStream.Close();

but System.IO.File.CreateText(filePath) seem not work in android then i try to

 StreamWriter outStream = new StreamWriter(Application.dataPath+ "/Resources/TurretInfo3.csv");

or

 StreamWriter outStream = new StreamWriter(Application.persistentDataPath+ "/Resources/TurretInfo3.csv");

but both not work, Thanks guys for help

Resources and Assets don’t exist at runtime. You’ll want to write to the regular file system.

4 Likes

To further clarify, what are you trying to do? If you want a regular .csv that you can open in excel, you need to write it to “/sdcard/yourfilepath”. You’ll also need to set up the permissions in the platform settings.

If you just need something that your game can read and write, then using Application.persistantDataPath should work fine.

Also make sure the folder exists before you try and write to it.

1 Like

the csv contain infomation of character(turret) and i can modify the *csv, so i need place *csv to some where to read it first.
At my code i drag *csv from “resources” to script and my app still ok when run in android but you said “resources” doesnt exit?

Thank you