embedded text file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter van der veen

    #1

    embedded text file

    Hi

    I have a VB project and added a text file to it as an embedded
    resource.

    But i can'f find a way now how to read this file just as a normal text
    file with the streamreader command.

    Anyone can give me a hint?

    Peter
  • Truong Hong Thi

    #2
    Re: embedded text file

    Stream resStream =
    Assembly.GetExe cutingAssembly( ).GetManifestRe sourceStream(th is.GetType(),
    fileName)

    Remember to close the stream.

    Peter van der veen wrote:
    Hi
    >
    I have a VB project and added a text file to it as an embedded
    resource.
    >
    But i can'f find a way now how to read this file just as a normal text
    file with the streamreader command.
    >
    Anyone can give me a hint?
    >
    Peter

    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: embedded text file

      <Peter van der veenschrieb:
      I have a VB project and added a text file to it as an embedded
      resource.
      >
      But i can'f find a way now how to read this file just as a normal text
      file with the streamreader command.
      \\\
      Imports System.IO
      ..
      ..
      ..
      Dim f As Stream =
      System.Reflecti on.Assembly.Get EntryAssembly() .GetManifestRes ourceStream( _
      "<Name of the root namespace>.test .txt" _
      )
      Dim st As New StreamReader(f)
      MsgBox(st.ReadT oEnd())
      st.Close()
      ///

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

      Comment

      Working...