Skip to content

Instantly share code, notes, and snippets.

@amimaro
Last active March 19, 2018 12:33
Show Gist options
  • Save amimaro/fa9f9f926a370fc079cd9ad936ce6814 to your computer and use it in GitHub Desktop.
Save amimaro/fa9f9f926a370fc079cd9ad936ce6814 to your computer and use it in GitHub Desktop.
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