write to a text file in resrouce folder

i have a text file in my resource folder which i can read. i am just wondering how can i write to it and save it?

this is the code i use to access my text file in the folder:

var tempAsset: TextAsset = Resources.Load("2011", TextAsset);
var myString: String = tempAsset.text;

Only through editor scripts. See AssetDatabase.SaveAssets and EditorUtility.SetDirty. Note that you can not call these functions from game scripts. It has to be in the editor. Otherwise you can check out this question which might be similar to your needs. It works on standalone players.

import System.IO;

var myString : String = "Write some text!";
var file : String = "somefile.txt";

Load();

function Load()
{
    myString = File.ReadAllText(file);
}

function Save()
{
    File.WriteAllText(file, myString);
}

http://forum.unity3d.com/threads/5084-Can-I-read-and-write-text-files-using-Javascript

That should help you a little... I recomend searchign around a little first =). But good job finding out how to read!

in JS… THIS WORKS!:slight_smile:

import System.IO;
 
function writeStuffToFile(){
  var stuff : String = "stuff";
  File.WriteAllText(Application.dataPath +"/stuff.txt",stuff);
}
 
function readStufFromFile(){
  var stuff : String;
  stuff = File.ReadAllText(Application.dataPath +"/stuff.txt");
  Debug.Log(stuff);
}