Resources.

  • Thread starter Thread starter Doker
  • Start date Start date
D

Doker

Hi.

I have embedded resource file "hr.html" added to my project.
How to load it to a String varaible named "strht"?

Thanks,
Doker
 
It will be something like this:
Dim fname as string = "your app name goes here" & ".hr.html"
Dim sra As Reflection.Assembly =
Reflection.Assembly.GetExecutingAssembly
Dim str As IO.Stream = sra.GetManifestResourceStream(fname)
Dim buf() As Byte
ReDim buf(CInt(str.Length) + 100)
str.Read(buf, 0, CInt(str.Length))
Dim s as string =
Text.Encoding.Default.GetString(buf,0,cint(str.length))
' at this point, string s should contain the contents of your file
This code is a cut/paste/edit of some of my code that works for wav files as
embedded resources. But I have edited it, so you may need to tinker. If
your project is "foo" and you have added file as a resource as simply as
possible, then the value of fname should be "foo.hr.html". You may need to
fiddle with the Text.Encoding line because that one I just winged.
 
Back
Top