Hi,
I have displayed word document in HTML format in .aspx page, but the embedded HTML file replaces "space" as "?" special character.
How can I remove the special character?
Here is the code I used for your reference:
try
{
string strFileName = fUpload.FileName;
string[] strSep = fUpload.FileName.Split('.');
int arrLength = strSep.Length - 1;
string strExt = strSep[arrLength].ToString().ToUpper();
strPathToUpload = Server.MapPath("Uploaded");
strPathToConvert = Server.MapPath("WordToHtml");
object FileName = strPathToUpload + "\\" + fUpload.FileName;
object FileToSave = strPathToConvert + "\\" + fUpload.FileName + ".htm";
if (strExt.ToUpper().Equals("DOC"))
{
fUpload.SaveAs(strPathToUpload + "\\" + fUpload.FileName);
lblMessage.Text = "File uploaded successfully";
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);
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";
}
else
{
lblMessage.Text = "Invalid file selected!";
}
objWord.Quit(ref missing, ref missing, ref missing);
string[] strHtml = System.IO.Directory.GetFiles(strPathToConvert);
Response.ContentType = "text/html";
Response.WriteFile(strHtml[0]);
Can you please help me out in this.
Thanks in advance.