Skip to main content
Search our knowledge base

How do I read and write data from a text file?



  • Nishal John

    This was exactly what I was looking for to create a Log System. Thanks!

  • Ben

    Does streamwritting work on all platforms, mobile & webplayer for example?

  • Fran D.

    The [MenuItem("Tools/XXXX file")] part is misleading because is not needed to solve the problem and what is worse it's use (which is not straightforward) it's not explained: not even a screenshot nor anything


  • Andrew Watson

    If you are developing for Hololens or mixed reality, you'll need to pass a stream in. This works fine for working in the editor, but when you try to build a solution under Universal Windows Platform, you'll get an error. Here's what I did:


    using (StreamWriter sw = new StreamWriter(new FileStream("Assets/" + FileName + ".txt", FileMode.OpenOrCreate, FileAccess.Write)))

    string line = "";

    //logic logic logic


    catch (Exception e)




  • Contractor Nation

    perfect! I needed TextAsset.text for Quest to read from Assets/myFile.html and used StreamWriter for Quest to write to /sdcard/Android/data/myPkgId/files, and a PC player can access the sdcard via adb

  • AwsApps

    is there a way to format the code?

  • Kaldrin

    Very useful article thank you

  • Bruno Araújo

    Sensacional! Sou do brazil and I'm still using the translator.. I have a small company where I deploy the crm bitrix, I'm not a programmer I just deploy crm training processes and if anyone is interested in exchanging ideas about deploying unity solutions because there is a lot of demand for AI bot apps and always wanted to work in the corporate system but together with free open communities (of course, always complying with the rule and agreement)... any Brazilians? congratulations for the project and for everyone in the community.

  • အဖွဲ့အစည်းတစ်ခုတွင်၊ အဖွဲ့ဝင်များသည် ပိုင်ရှင်၊ မန်နေဂျာ သို့မဟုတ် သုံးစွဲသူများအပေါ်မူတည်၍ မတူညီသောခွင့်ပြုချက်များရှိသည်။ သင့်အခန်းကဏ္ဍပေါ် မူတည်၍ သင့်တွင် အဖွဲ့အစည်းသို့ ဝင်ရောက်ခွင့် အမျိုးမျိုးရှိသည်။


Please sign in to leave a comment.