Home All Groups Group Topic Archive Search About
Author
7 Sep 2006 9:45 AM
Peter van der veen <>
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

Author
7 Sep 2006 12:11 PM
Truong Hong Thi
Stream resStream =
Assembly.GetExecutingAssembly().GetManifestResourceStream(this.GetType(),
fileName)

Remember to close the stream.

Peter van der veen wrote:
Show quoteHide quote
> 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
Author
7 Sep 2006 12:50 PM
Herfried K. Wagner [MVP]
<Peter van der veen> schrieb:
> 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.Reflection.Assembly.GetEntryAssembly().GetManifestResourceStream( _
    "<Name of the root namespace>.test.txt" _
)
Dim st As New StreamReader(f)
MsgBox(st.ReadToEnd())
st.Close()
///

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