Skip to content

Instantly share code, notes, and snippets.

Last active March 19, 2018 12:33
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Read and Write files with Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Text;
using System.IO;
public class UnityReadWriteFile : MonoBehaviour
void Start ()
void Update ()
string ReadFile (string path)
StreamReader sr = new StreamReader (path, Encoding.UTF8);
string data = sr.ReadToEnd ();
sr.Close ();
return data;
void WriteFile (string path, string data)
StreamWriter sw = new StreamWriter (path);
sw.WriteLine (data);
sw.Close ();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment