title: How can I do reading and writing TextAssets at runtime with Unity 3D?
body: <p>I have my desired txt files which I want to use as TextAssets. I need these files to be usable at runtime by my other scripts. Now the issue is that I can not figure out a way to make these things work.</p>
  
  <p>I know that I should be using the Assets/Resources or the Streaming Assets folder but for some reason things are not working properly. Is there a way to incorporate it all with StreamWriters and Filestreams? What about TextAssets assigned in Unity Editor, can those also be setup as Streaming?
  Some examples of code that uses my assets:</p>
  
  <pre><code>    public void TaskOnClick() //getting multi-values
      {
          string filename = "Assets/Resources/TempoText/multi-export.txt";
          using (StreamWriter writeFile = new StreamWriter(filename, false))
          {
              foreach (string inputJson in File.ReadLines("Assets/Resources/TempoText/multi-import.txt"))
              {
                  string temperature = GetTemperatureByRegex(inputJson);
                  Debug.Log(temperature);
                  writeFile.AutoFlush = true;
                  Console.SetOut(writeFile);
                  writeFile.WriteLine(temperature.ToString());
              }
  
          }
          File.Copy("Assets/Resources/TempoText/multi-export.txt", "Assets/Resources/multi-export.txt", true);
      }
  //or
  
          FileStream filestream = new FileStream("Assets/Resources/TempoText/multi-import.txt", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
          var writeFile = new StreamWriter(filestream);
  
          {
              var document = collection.Find(new BsonDocument()).Sort(sort).Limit(limit: limit).ForEachAsync(d =&gt; Console.WriteLine(d)); //displays last 10 entries
              Debug.Log(document.ToString());
              writeFile.AutoFlush = true;
              Console.SetOut(writeFile);
              writeFile.Write(document.ToString());     
          }
  
  
  </code></pre>
  
  <p>All help greatly appreciated, I've basically messed up big time since I only found out about this now when I built everything as is...</p>
  
  <p>Edit: got the streamwriters to do everything nicely with Application.persistentDataPath! Now stuck with a problem that I already struggled with - how to assign a TextAsset to get the file from a fixed path...</p>
  
  <pre><code>public TextAsset textFile; 
  </code></pre>
  
  <p>Wondering how to set this to get it's .txt from Application.persistentDataPath</p>