This is a migrated thread and some comments may be shown as answers.

Exception during Import

3 Answers 50 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Liang
Top achievements
Rank 1
Liang asked on 05 Dec 2011, 07:53 AM
The following code will throw an exception indicating "Dir not found". It seems that while importing from a string, RadRichTextBox will need to access a certain folder that does not exist.
In my project, I need to serialize the content(The content might contain some InlineUIContainer which includes a TextBlock) of the RichTextBox into the OpenXml format and unserialize it back, could you please provide any better solutions?

public static RadDocument ImportFromString(string content)
{
    var provider = new DocxFormatProvider();
 
    var stream = new MemoryStream();
    var sw = new StreamWriter(stream);
    sw.Write(content);
 
    return provider.Import(stream);
}

3 Answers, 1 is accepted

Sort by
0
Mihail
Telerik team
answered on 07 Dec 2011, 06:17 PM
Hello Liang,

The docx format is binary (being compressed using ZIP) so you can't pass it as string. If you keep your data in MS SQL, you can set the field type to image and everything should be fine. Other databases call the binary field with other names, such as BLOB.
If this is not the case we will need more information on how you keep you data in order to help you further.

All the best,
Mihail
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Liang
Top achievements
Rank 1
answered on 08 Dec 2011, 06:51 AM
Thanks a lot for your reply.

the "content" is stored as a string in the OpenXml format. I saw that there was an assmebly "Telerik.Windows.Documents.FormatProviders.OpenXml.dll", so I followed your example with this assembly.

Anyway, my intention is the ability to import/export using the OpenXml format.

Thanks again for your help.
0
Boby
Telerik team
answered on 13 Dec 2011, 09:56 AM
Hi Liang,
As Mihail pointed out in his previous post, docx format is binary, so it cannot be stored as string. The best text-based format you can use is our internal XAML format (read more about available formats here), as it represents fully our internal document structure.

Regards,
Boby
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
RichTextBox
Asked by
Liang
Top achievements
Rank 1
Answers by
Mihail
Telerik team
Liang
Top achievements
Rank 1
Boby
Telerik team
Share this question
or