Prasad
Prasad

Reputation: 131

File format is invalid for .rtf format

Currently i am working on VSTO with C#.net. I am having a form where i am have one DropDownList and a RichTextBox. When I select an item in the list, the xmldata(tags)from the database has to be shown in RichTextBox.

Here is the code snippet:

rtbReuseData.Rtf= xElement.Element(DropDown.Value).Value;

Now, when i am selecting an item from the DropDownList, it is showing an error "File format is Not valid". (When i take the .text instead of .rtf, it is showing some data but is not of format.)I want to show xml format data in the Richtextbox.

Please help me in getting this problem solved.

Thanks, K.S.Reddi Prasad.

Upvotes: 2

Views: 2244

Answers (1)

Restart
Restart

Reputation: 57

Try trim your value's beginning and ending char '\r' and '\n'.

You can do something like following: :)

rtbReuseData.Rtf = xElement.Element(DropDown.Value).Value.TrimStart("\r".ToCharArray()).TrimStart("\n".ToCharArray()).TrimEnd("\r".ToCharArray()).TrimEnd("\n".ToCharArray());

Upvotes: 0

Related Questions