Hey everyone,
how do i find and highlight a specific word in a .txt file?
I only have this until now :
this.openFileDialog1.Filter = "TEXT (.xml;.txt|";
this.openFileDialog1.Multiselect = true;
this.openFileDialog1.Title = "My text editor";
DialogResult dr = openFileDialog1.ShowDialog();
if (dr == DialogResult.OK)
and i want to find these two words : "game" and "player" within a .txt file and highlight them if they're found.

i already checked them out. i dont want to have a richtext. i want to have an openfiledialog that opens files (.txt) and finds and highlights the words game and player. so highlighting only these two words "game" and "player" in multiple files.

  private void button1_Click(object sender, EventArgs e)
        {
            this.openFileDialog1.Filter =
                "TEXT (*.xml;*.txt|";
            this.openFileDialog1.Multiselect = true;
            this.openFileDialog1.Title = "My text editor";
            DialogResult dr = openFileDialog1.ShowDialog();
            if (dr == DialogResult.OK)
                foreach (String file in openFileDialog1.FileNames)
                    try
                    {
                        StreamReader reader = new StreamReader(file);
                        string content = reader.ReadToEnd();
                        reader.Close();
                        content = Regex.Replace(content, "game", "punt");                 

basically what this code does but not replace it, only highlights the word "game".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.