I am usually in the VB.Net forum..I am trying to convert to C# from VB.Net...
I am creating a program that the user can enter test results and save them to a text file...then they can fill the listview with the saved text file. I have the program loading an ArrayList with each line of the text file....one problem I see is the arraylist.....as it is right now it is only 5 lines long...the text file will get larger everytime the user saves the test results.
so I guess my question is , how would I get the text file contents into a list?
maybe use a List(of Integer) or List(of String)?
the text file looks like this
here is the code I have
this works good...but if the text file gets larger , it doesnt......I know I need to add the text contents to something other than a ArrayList...but kinda lost now
Thanks for any Help
InkedGFX
I am creating a program that the user can enter test results and save them to a text file...then they can fill the listview with the saved text file. I have the program loading an ArrayList with each line of the text file....one problem I see is the arraylist.....as it is right now it is only 5 lines long...the text file will get larger everytime the user saves the test results.
so I guess my question is , how would I get the text file contents into a list?
maybe use a List(of Integer) or List(of String)?
the text file looks like this
2/2/2013 5:14:36 PM
122
2223
223
555
this is a test Note!
here is the code I have
private void frmViewResults_Load(object sender, EventArgs e) { // read the text file StreamReader sr = new StreamReader(Application.StartupPath + [URL="file://\\SugarData.txt""]\\SugarData.txt"[/URL], False); string strLine = ""; // fill the ArrayList with the contents of the text file ArrayList Numbers = new ArrayList(); while (strLine != null) { strLine = sr.ReadLine(); if (strLine != null) Numbers.Add(strLine); } sr.Close(); // fill variables from arrayList string date = Numbers[0].ToString(); string firstNum = Numbers[1].ToString().Trim(); string secondNum = Numbers[2].ToString(); string thirdNum = Numbers[3].ToString(); string fourthNum = Numbers[4].ToString(); string note = Numbers[5].ToString(); // fill ListView from variables ListViewItem lvi = new ListViewItem(date); lvi.SubItems.Add(firstNum); lvi.SubItems.Add(secondNum); lvi.SubItems.Add(thirdNum); lvi.SubItems.Add(fourthNum); lvi.SubItems.Add(note); LVResults.Items.Add(lvi); }
this works good...but if the text file gets larger , it doesnt......I know I need to add the text contents to something other than a ArrayList...but kinda lost now
Thanks for any Help
InkedGFX
Last edited: