I am not sure if I am doing this right as I am new to C#. I am just trying to get it to read a line from the file so I can continue moving forward. It’s a .CSV file and I get the following error:
error CS0103 The name ‘file’ does not exist in the current context.
The file is in the Assets folder. I am using a mac and tried the file with its path “/user/computername/projectname/assets/filename.csv”
//begin code fail
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
public class ReadCSV : MonoBehaviour
{
// Use this for initialization
void Start ()
{
//I tried adding the path before the filename too but no love
StreamReader sr = file.OpenText(“filename.csv”);
//just trying to read ONE line to get this file to be read, no loop here
string line;
line = sr.ReadLine();
print(line);
}
// Update is called once per frame
void Update ()
{
}
} //end code fail
let me know if you have a better suggestion for implementing this. I had it reading this file fine with a different version but due to my poor version control it just stopped reading the file for some reason.