How can I load an embedded rich text file into a richtextbox

Platform: WinForms|Category: RichTextBox

You use the LoadFile method of the RichTextBox, passing it a streamreader based on the resource. So include your RTF file as an embedded resource in your project, say RTFText.rtf. Then load your richtextbox with code such as

	Stream stream = this.GetType().Assembly.GetManifestResourceStream('MyNameSpace.RTFText.rtf');
	if (stream != null)
	{
 		StreamReader sr = new StreamReader(stream);
 		richTextBox1.LoadFile(stream, RichTextBoxStreamType.RichText);
 		sr.Close();
	}

Here is a VB snippet. Depending on your default namespace settings, you may not need explicit reference to the namespace in the GetManifestResourceStream argument.

	Dim stream As Stream = Me.GetType().Assembly.GetManifestResourceStream('MyNameSpace.RTFText.rtf')
	If Not (stream Is Nothing) Then
   		Dim sr As New StreamReader(stream)
   		richTextBox1.LoadFile(stream, RichTextBoxStreamType.RichText)
   		sr.Close()
	End If