0

Having trouble figuring this out.

I have to read text files with data and want to convert each of them into an array.

DataList

dataOne
dataTwo
dataThree
etc.....

ItemList

listOne
listTwo
listThree
etc.....

so read the Items and store them in a list

List<string> dataList = new List<string>();
List<string> itemList = new List<string>();

Then Console.WriteLine the list

Console.WriteLine(dataList[0] + itemList[0]);

I have been trying to use StreamReader to input the text files, but it doesn't seem to add them to a array

string dataListFile = @"..\..\FileIOExtraFiles\DataFieldsLayout.txt";
            StreamReader dataFile = new StreamReader(dataListFile);
ydoow
  • 2,969
  • 4
  • 24
  • 40
Daniel Rubio
  • 49
  • 12

1 Answers1

2

Refer to https://msdn.microsoft.com/en-us/library/s2tte0y1(v=vs.110).aspx

string path = @"..\..\FileIOExtraFiles\DataFieldsLayout.txt";
string[] dataList = File.ReadAllLines(path);
ydoow
  • 2,969
  • 4
  • 24
  • 40