Help with Embedded Resource

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ed Bitzer

    Help with Embedded Resource

    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_assem bly.GetManifest ResourceStream( my_namespace +
    ".text1.txt ")
    If Not (text_stream Is Nothing) Then
    Dim stream_reader As New StreamReader(te xt_stream)
    Label1.Text = stream_reader.R eadToEnd()
    stream_reader.C lose()
    End If

    Appreciate,

    Ed


  • Ed Bitzer

    #2
    Re: Help with Embedded Resource

    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.Rt f =
    My.Resources.my rtfhelpfile. 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

    "Ed Bitzer" <edbitzer@yahoo .comwrote in message
    news:eHAfwh3xIH A.420@TK2MSFTNG P02.phx.gbl...
    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_assem bly.GetManifest ResourceStream( my_namespace +
    ".text1.txt ")
    If Not (text_stream Is Nothing) Then
    Dim stream_reader As New StreamReader(te xt_stream)
    Label1.Text = stream_reader.R eadToEnd()
    stream_reader.C lose()
    End If
    >
    Appreciate,
    >
    Ed
    >
    >

    Comment

    • =?Utf-8?B?Sm9obg==?=

      #3
      Re: Help with Embedded Resource

      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.(y our
      resource name) -- Visual Studio 2008, VB.net 2008

      Thanks Ed, this saved me a lot of time!



      "Ed Bitzer" wrote:
      >
      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.Rt f =
      My.Resources.my rtfhelpfile. That is it, one line of code.
      >

      Comment

      Working...