title: How to read a .doc and .docx file in Asp.Net MVC3 and display in TextBox
body: <p>I have a View with Browse and Submit button.When the User Clicks on browse a .doc or .docx file can be browsed and when the Submit button is clicked the selected file's Text should get populated in the TextBox on the same View.
  Below is my code to read and Display the Text in TextBox.</p>
  
  <pre><code>            string filePath =null,docText=null;
              foreach (string inputTagName in Request.Files)
              {
                  HttpPostedFileBase Infile = Request.Files[inputTagName];
                  if (Infile.ContentLength &gt; 0 &amp;&amp; (Path.GetExtension(Infile.FileName) == ".doc"))
                  {
                      filePath = Path.Combine(
                      AppDomain.CurrentDomain.BaseDirectory,
                      Path.GetFileName(Infile.FileName));
                      if (System.IO.File.Exists(filePath))
                      {
                          System.IO.File.Delete(filePath);
                      }
                      Infile.SaveAs(filePath);
                  }
                  if (filePath != null)
                  {
  
                      docText = System.IO.File.ReadAllText(filePath);
  
                  }
                  ViewBag.displayTextInTextBox= docText;
              }
              return View();
  </code></pre>
  
  <p>Below is my View Code </p>
  
  <pre><code>&lt;input type="text" id="test1" name="test" value="@ViewBag.displayTextInTextBox"&gt;
  </code></pre>
  
  <p>Its showing Special characters(like this ��ࡱ� ) rather than the Text in the .doc/.docx document.
  Am i reading the file incorrectly or what's the issue in my code.</p>