Hello! Im trying to create .txt file and read it`s information. Everything works great exept one
thing - first line is skipped. How can i fix this issue?
using UnityEngine;
using System.Collections;
using System.Text;
using System.IO;
public class menuManager : MonoBehaviour {
private string path;
string[] lines;
// Use this for initialization
void Start ()
{
path = Application.dataPath+ "/MyTxT.txt";
using (FileStream fs = File.Create(path))
{
for (int i = 0; i < 3; i++)
{
AddText(fs, "
false");
}
}
lines = System.IO.File.ReadAllLines(path);
foreach (string line in lines)
{
// Use a tab to indent each line of the file.
Debug.Log(line);
}
windowRect = new Rect (Screen.width/2-100, Screen.height / 2 - 200 , 200, 400);
}
private static void AddText(FileStream fs, string value)
{
byte info = new UTF8Encoding(true).GetBytes(value);
fs.Write(info, 0, info.Length);
}
}