Last active
March 19, 2018 12:33
-
-
Save amimaro/fa9f9f926a370fc079cd9ad936ce6814 to your computer and use it in GitHub Desktop.
Read and Write files with Unity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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