Results 1 to 40 of 43

Thread: Getting specified text from text file

Threaded View

  1. #25
    Fanatic Member AceInfinity's Avatar
    Join Date
    May 2011
    Posts
    696

    Re: Getting specified text from text file

    Try this:

    vb Code:
    1. listBox1.Items.Clear();
    2.  
    3. using (StreamReader sr = new StreamReader(textBox1.Text + @"\Game\Game.LOG"))
    4. {
    5.     while (sr.Peek() > -1)
    6.     {
    7.         string ln = sr.ReadLine();
    8.         if (ln.Contains(" joined the match."))
    9.         {
    10.             string values = (from Match m in Regex.Matches(ln, @"""(.*?)""", RegexOptions.IgnoreCase)
    11.                              select m.Value).ToArray()[0];
    12.  
    13.             //string status = ln.Contains("disco") ? "" : "";
    14.             textBox1.Text += values.Replace((char)34, '\n')  + Environment.NewLine;
    15.         }
    16.     }
    17. }
    18.  
    19. string[] arr = textBox1.Lines;
    20. textBox1.Text = String.Join(Environment.NewLine, arr.Distinct().ToArray());

    This will remove all the duplicates. Assuming that your display "2/16" is correct. I'm not sure how your validating that.
    Last edited by AceInfinity; Apr 12th, 2012 at 03:20 PM.
    <<<------------
    Improving Managed Code Performance | .NET Application Performance
    < Please if this helped you out. Any kind of thanks is gladly appreciated >


    .NET Programming (2012 - 2018)
    ®Crestron - DMC-T Certified Programmer | Software Developer
    <<<------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width