Kredns
Kredns

Reputation: 37231

What's the best way to save a RichTextFile in C#?

I'm trying to create a notepad/wordpad clone. I want to save it in .rtf format so that it can be read by wordpad. How do I save a do this in C#?

Upvotes: 0

Views: 1070

Answers (3)

Rex M
Rex M

Reputation: 144182

Assuming you are trying to do this yourself for learning purposes, you don't want to use a library to do it for you:

Basically you need to write a program which holds in memory either a string with RTF markup, or a DOM-like data tree. Using the RTF specification, you should write a flat (text) file marked up properly and with a .rtf extension. Just the same as if you were writing an HTML file.

Upvotes: 2

Srikar Doddi
Srikar Doddi

Reputation: 15609

RTF SpecLink

create the xml spec based on their api and you can make your app compatible with wordpad, word etc.

Upvotes: 0

Anthony
Anthony

Reputation: 7146

Correct me if I'm wrong, but if you're using the RichTextBox control, you can just use the RichTextBox.SaveFile method to accomplush this. Just a guess though that you mean doing it without using that control.

Upvotes: 1

Related Questions