Help with Embedded Resource

  • Thread starter Thread starter Ed Bitzer
  • Start date Start date
E

Ed Bitzer

I posted this on the MS's MSDN forum but found no interest in helping
so returning to my reliables<g>
I have an embedded resourse, a small rtf file, which I would like to
display in a rich text box. The following code places a text file in
a label after getting the assmbly and namespace - is there as the
parallel construciton for the rtf file?
Dim text_stream As Stream =
executing_assembly.GetManifestResourceStream(my_namespace +
".text1.txt")
If Not (text_stream Is Nothing) Then
Dim stream_reader As New StreamReader(text_stream)
Label1.Text = stream_reader.ReadToEnd()
stream_reader.Close()
End If

Appreciate,

Ed
 
Have learned how to both embed resources and use in my program - the
hard way<g>, a lot of Google searches and a lot of trial and error.
What took several lines of code with version 1.1 of the net framework,
now with Visual Studio, VB8 and Net 2.0, it is cut and paste.

First to embed resources you simply have to double click on the
"Resources.resx" folder under Solution Explorer and a dialog appears
which permits you to "Add." Once added they may be used by
referencing via My. Resources as for example, in my case where I
wanted to display a rtf file: RichTextBox1.Rtf =
My.Resources.myrtfhelpfile. That is it, one line of code.

What a nice way to embed some help instructions with out creating a
separate chm file, keep the content with a single exe, and yet take
advantage of the flexibility of an rtf file including hyperlinks.

Ed
 
To clarify, the 'Resources' area is listed in the Solution Explorer
properties of your project. You right click on your solution and choose
properties. Once in the properties area you can select the resources tab and
add your file, images or other items. The rest is My.Resources.(your
resource name) -- Visual Studio 2008, VB.net 2008

Thanks Ed, this saved me a lot of time!
 
Back
Top