title: How to read word document contents using string builder?
body: <p>I have uploaded a file into server. How can I use c# to read the contents and display it.
  I used string builder to extract the content, and display it in a multiline textbox.</p>
  
  <p>The code I used is :-</p>
  
  <pre><code>string[] readText = File.ReadAllLines(path);
  
  StringBuilder strbuild = new StringBuilder();
  foreach (string s in readText)
  {
      strbuild.Append(s);
      strbuild.AppendLine();
  }
  txtPreview.Text = strbuild.ToString();
  </code></pre>
  
  <p>The problem with this is that, some kind of additional un-readable character are displayed at the top and bottom, maybe some kind of encrypted text. How to remove those charactes, and show only the contents ?</p>
  
  <pre><code>Microsoft.Office.Interop.Word.Document doc = Application.Documents.Open(ref file, ref nullobj, ref nullobj,
                                                    ref nullobj, ref nullobj, ref nullobj,
                                                    ref nullobj, ref nullobj, ref nullobj,
                                                    ref nullobj, ref nullobj, ref nullobj,
                                                    ref nullobj, ref nullobj, ref nullobj, ref nullobj);
  doc.Activate();
  string Doc_Content = doc.Content.Text;
  string str = Doc_Content;
  var words = str.Split(new char[] { ' ', ':', '\r', '\t' });
  
  for (int i = 0; i &lt; words.Length; i++)
  {
      string val1 = words[i].ToString();
  }
  </code></pre>
  
  <p><strong>UPDATE:
  I am using Microsoft Interop library, and I am able to show the contents of the word document into the multiline text box.</strong></p>
  
  <p>I created a string variable str to hold all content of the word file. And an array word[] to store the words.
  The problem I am facing now is :-
  Read the words. If the first word is "hello", I need to read the second and third word.
  If the first word is "hello" and second word is "world", I need to read the third and fourth words. Other wise, I need to read the first and second words.
  How can this be done?</p>