reading text files into array
i have a text file with a list of values.
i need to read them into an array in visual studio in a windows form.
this is called form1.cs. I also have a class called TrafficSensor. see below. how can i read these values into an array in the form and print them into a label? cheers 4 any help!
using System;
using System.IO;
namespace Workshop1
{
public class TrafficSensor
{
private StreamReader inFile;
private string fileText;
public TrafficSensor(string trafficFile)
{
try
{
fileText="test";
inFile = new StreamReader(trafficFile);
}
catch (Exception e)
{
Console.WriteLine("Could open traffic simulator file. "+e);
}
}
public string ReadTrafficSensor()
{
return fileText = inFile.ReadLine();
}
}
}