Using SttreemWriter and WriteLine to try to save my last recorded time data for a game that shows how long it took to do something. No errors but the data is not saving
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.UI;
public class KeepTime : MonoBehaviour
{
public Text timerText;
private float startTime;
public string pathName = @“C:\BME 673 UnityData\Time.txt”;
// Start is called before the first frame update
void Start()
{
startTime = Time.time;
}
// Update is called once per frame
void Update()
{
if (KeepScore.Score >= 4)
{
timerText.color = Color.yellow;
enabled = false;
writetimerText();
return;
}
float t = Time.time - startTime;
string minutes = ((int)t / 60).ToString();
string seconds = (t % 60).ToString("f2");
timerText.text = minutes + ":" + seconds;
}
private void writetimerText()
{
using (System.IO.StreamWriter file = new StreamWriter(pathName, true))
{
string output = string.Format("{0},seconds", timerText);
file.WriteLine(timerText);
}
}
private void clearFiles()
{
using (System.IO.StreamWriter file = new StreamWriter(pathName, false))
{
}
}
}