We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Load a .DOC file into a Web Text Editor

I am using a rich text editor from Telerik in my application. I recently purchased your Words module and am now trying to load this editor with a file selected by using a fileupload control to locate the file to upload, an web button control to fire the upload event, and the ASPOSE Words engin to load the file to the editors content area.

So far this is what I have tried, but it does not load the formatted document. What it loads in the content area is the literal "Aspose.Words.Document".

string filepath = WBSFileBrowse.PostedFile.FileName;

Document doc = new Document(filepath, Aspose.Words.LoadFormat.Doc, null);

WBSDecriptionEditor.Content = doc.ToString();

What am I doing wrong?? Could you provide an example??


Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Please try using the following code:

//Open existing document

Document doc = new Document(@"Test289\in.doc");

//Save document into stream

MemoryStream rtfStream = new MemoryStream();

doc.Save(rtfStream, SaveFormat.Rtf); //If you need HTML string then use SaveFormat.Html

//Get rtf string

string rtfString = Encoding.UTF8.GetString(rtfStream.GetBuffer(), 0, (int)rtfStream.Length);

Hope this helps.

Best regards.

Thanks for the quick response.

I get a compile error saying that 'Endcoding' does not exist in current context. Am I missing an assembly reference, and if so, what would it be.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. You missed the following:

using System.Text;

Best regards.