I was wondering if it is possible using streamwriter to make some of the text you write to a file bold I have been trying to figure this out, and have no luck in searching various websites if it is possible.
What I am trying to do is, write to an .rtf file and have for example: "Name:" in bold and then the person's name normal style afterwards. If you can't using streamwriter and there is a way, any help would be appreciated.
Thanks in advance.

Writting to a file
imranabdulaziz
Name:
Do I have to add the whole {\rtf1\ansi....} line or should \b and \b0 work without it. If I do, how should I go about it Adding the \rtf1 line to a serperate string perhaps
Thanks in advance, this is my first time really working with writting to files.
Sterling Swartwout
This solves the last problem I had with writting to the file, so thanks a lot. I would have ended up probably throwing my monitor out the window trying to figure this out on my own
williambeaker
One extra thing, I've found that when using both the rtfTextBoxes and the normal textBoxes, that if it contains a number, it won't print to the file. If its just a regular word it will print straight to the file, but if it involves a number it doesn't output anything.
If you know what could be causing this I would love to know, cause this has me floored right now. The one thing I'm guessing it might be is that I might need more of the rtf1 header, but I've copied pretty much the entire header from my test .rtf file with no results. I can't even use: "\\b 123 \\b0", but if it was "\\b ABC \\b0" it would print to the file.
Any help on this would be appreciated.
Nathan R
The header string should be the first thing you write to the file, right after you open it for writing.
Edit:
Alright, I decided to see what the minimal data required is, and it seems to be the following:
{\rtf1
\b some bold text\b0 back to normal text\par This is on a new line.
}
So when you open the stream, first write out "{\rtf1", then the text you want with \b and \b0 tags as needed and using \par for line breaks. Finally, write out the closing } before you close the file. You will have to escape the backslashes with an extra backslash "{\\rtf1", or like @"{\rtf1". If you want to set the fonts, etc. then you'll want to keep more of the header.
carol chen
{\rtf1
\b 123\b0
}
and the numbers showed up in both Word and wordpad.
Open notepad, and then open the rtf file that you tried to get the numbers to show up in. If the numbers aren't there in the plaintext, then the problem must be with how you are writing the numbers to the file. If the numbers are there, then there is something wrong with the formatting (like if you forgot a space after a \\b or something).
In either case, post the contents of the rtf file (with the header, etc.) and the code you are using to generate it, and we can get this figured out.
Michael Hansen
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.21.2500;}\viewkind4\uc1\pard\b\f0\fs20 bold\b0 normal\par
}
The \b and \b0 commands are what causes the bold text. Take a look at the RTF Specifications for more information.
You can also use the RichTextBox control to save and edit the file.