title: how to convert .doc or .docx to html c#
body: <p>help me I dint know how to combine this code.Hope anyone can help me. I using c# in asp.net and try to convert .doc and .docx to html to view in webpage. </p>
  
  <p>This is my code:</p>
  
  <pre><code>public bool WriteViewRow(DataRowView drv)
      {
          string strFileLink = null;
          string strFileName = Convert.ToString(drv["Name"]);
          string strFilePath = WebPathCombine(WebPath(), strFileName);
          bool blnFolder = IsDirectory(drv);
  
          if (blnFolder)
          {
              if (!string.IsNullOrEmpty(_strHideFolderPattern) &amp;&amp; Regex.IsMatch(strFileName, _strHideFolderPattern, RegexOptions.IgnoreCase))
              {
                  return false;
              }
              strFileLink = PageUrl(strFilePath) + strFileName + "&lt;/A&gt;";
          }
          else
          {
              if (!string.IsNullOrEmpty(_strHideFilePattern) &amp;&amp; Regex.IsMatch(strFileName, _strHideFilePattern, RegexOptions.IgnoreCase))
              {
                  return false;
              }
                strFileLink = "&lt;A href=\"" + strFilePath + "\" target = \"iframe01\"&gt;" + strFileName + "&lt;/A&gt;";         //link to open the file
          }
  </code></pre>
  
  <p>And I want to use this code to join in my code, I don't want to upload the file but want to use the link in code above to integrate in this code:</p>
  
  <pre><code>//To check the file extension if it is word document or something else
  string strFileName = fUpload.FileName;
  string[] strSep = fUpload.FileName.Split('.');
  int arrLength = strSep.Length - 1;
  string strExt = strSep[arrLength].ToString().ToUpper(); //Save the uploaded file to the folder
  strPathToUpload = Server.MapPath("Datadir");  //Map-path to the folder where html to be saved
  strPathToConvert = Server.MapPath("WordToHtml");
  object FileName = strPathToUpload + "\\" + fUpload.FileName;
  object FileToSave = strPathToConvert + "\\" + fUpload.FileName + ".htm";
  
  if (strExt.ToUpper() == "DOCX" || strExt.ToUpper() == "DOC" )
  {
  
      fUpload.SaveAs(strPathToUpload + "\\" + fUpload.FileName);
      lblMessage.Text = "File uploaded successfully";
      //open the file internally in word. In the method all the parameters should be passed by object reference
  
      objWord.Documents.Open(ref FileName, ref readOnly, ref missing, ref missing, ref missing, ref missing,
      ref missing, ref  missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing,
      ref missing, ref missing);
  
      //Do the background activity
      objWord.Visible = false;
      Microsoft.Office.Interop.Word.Document oDoc = objWord.ActiveDocument;
  
      oDoc.SaveAs(ref FileToSave, ref fltDocFormat, ref missing, ref missing, ref missing, ref missing,ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
  
      lblMessage.Text = fUpload.FileName + " converted to HTML successfully";
      docPreview.Attributes["src"] = "../WordToHtml/" + fUpload.FileName + ".htm";
  
  }
  </code></pre>
  
  <p>Anyone have some advice?Actually I want to develop some webpage like webmanager and user be able to upload,delete,view,edit the file.. It's all have done if file .txt..but I fail to convert this.</p>