G
garyusenet
string[] lines = File.ReadAllLines(@"c:\text\history.txt");
foreach (string s in lines)
{
ArrayList results = new ArrayList();
string delimit = ";";
string[] currentline = s.Split(";");
MessageBox.Show(s);
}
I am trying to incorporate some basic database functionality into my
programme using a text file and arrays. I am not using 'database'
technologies because i dont understand them, and have spent days trying
to so am going back to a basic text file.
I'm have read the contents of a text file into an array called lines,
line by line. This works fine.
The file is structured so that each line represents one record.
Each line record follows this type of pattern : -
date ; time ; name ; address ; some other info ; some more info ;
etc...
I am trying to write some code that will return an array of records
that match a given name.
My idea was take each line of the file in turn, and split it into a
'currentline' array, I could then query the 2nd element of the
currentline array and check to see if it matches the search name.
If it does then I can add the currentline to the results array.
If it doesn't I can ignore it and examine the next line.
However it's not working, there's something wrong with the way i'm
using Split, it seems to be looking for an array delimiter and not a
single string.
Any ideas how I can get it to work please?
Thanks,
Gary.
foreach (string s in lines)
{
ArrayList results = new ArrayList();
string delimit = ";";
string[] currentline = s.Split(";");
MessageBox.Show(s);
}
I am trying to incorporate some basic database functionality into my
programme using a text file and arrays. I am not using 'database'
technologies because i dont understand them, and have spent days trying
to so am going back to a basic text file.
I'm have read the contents of a text file into an array called lines,
line by line. This works fine.
The file is structured so that each line represents one record.
Each line record follows this type of pattern : -
date ; time ; name ; address ; some other info ; some more info ;
etc...
I am trying to write some code that will return an array of records
that match a given name.
My idea was take each line of the file in turn, and split it into a
'currentline' array, I could then query the 2nd element of the
currentline array and check to see if it matches the search name.
If it does then I can add the currentline to the results array.
If it doesn't I can ignore it and examine the next line.
However it's not working, there's something wrong with the way i'm
using Split, it seems to be looking for an array delimiter and not a
single string.
Any ideas how I can get it to work please?
Thanks,
Gary.