Dan

Dan

  • NA
  • 1
  • 0

Modifying a text file

Jul 8 2009 5:33 PM
What I want the program to do is look through a .log file (a .txt file really) and find search through for certain strings.

What I have so far is
         private void button1_Click(object sender, EventArgs e)
{
string allies = @"C:\L0707161.log";
StreamReader alliestext = new StreamReader(allies);
string readall = alliestext.ReadToEnd();
alliestext.Close();
string alliesMatch = "<Allies>";
if (Regex.IsMatch(readall, alliesMatch))
{

}
else
{

}
}


The type of file it will be searching through looks like this

 L 07/07/2009 - 17:41:15: "Player<5><STEAM_0:0:00000000><Allies>" changed role to "#class_allied_heavy"
Only many more lines than that.

What I would like it to do is take the Player Name (in this case Player) and assign it to a variable
Take the steamid and assign it to a variable (in this case STEAM_0:0:00000000)
Finally store that persons team to a variable in this case (allies)

So for example

Players Name                     STEAM ID                            Team
Player                                 STEAM_0:0:00000000        Allies

Now some things I would also like to do is make it so one steamid doesnt show up multiple times because in the log file it will. So I think simply setting all of the variables to an arrray. so like playername(0) and so on then before writing them to the listbox or w/e control I decide to use, it checks for duplicates and if it is a duplicate it deletes one of them.


Something to keep in mind is that the steam_id will range in length aswell which is where I got stuck.