I am trying to develop an application using Windows Form to read the contents of a *.txt file with contains information below:
12.14,12.00,11.98,12.01,12.09,12.05, 11.50,11.48,11.56,11.52,11.53,11.48, 12.08,11.13,11.12,12.08,11.12,12.10, 12.14,12.00,11.98,12.01,12.09,12.05, 11.50,11.48,11.56,11.52,11.53,11.48, 12.09,11.12,11,09,12.12,11.16,12.12, 12.14,12.00,11.98,12.01,12.09,12.05, 11.50,11.48,11.56,11.52,11.53,11.48, 12.17,11.11,11.19,12.15,11.10,12.11, 12.14,12.00,11.98,12.01,12.09,12.05,
and need to copy each of individual values into a TextBox (there are a total of 60 TextBox's).
I tried to use code below, but I have no idea how to work with all TextBox's individually.
using System;
using System.IO;
public class Sample
{
public static void Main() {
using (StreamReader reader = new StreamReader("yourfile.txt")) {
string line = null;
while (null != (line = reader.ReadLine())) {
string[] values = line.Split(',');
float[] numbers = new float[values.Length - 1];
for (int i = 1; i < values.Length - 1; i++)
numbers[i - 1] = float.Parse(values[i]);
}
}
}
}
(this code was copied from URL How to read values from a comma separated file?)