I would like to use embedded text files in a .NET DLL I am building. I have added the text files in a subfolder of the project and added the relevant code to AssemblyInfo.vb. The subfolders are residing in the MyProject > Templates > Text folder.
I need to read in the embedded text files (much like a web app would read in a normal .txt file) but I am unsure as to how to do this. The namespace/filename I am using to access the file is MyProject.Templates.Text.T
e.txt where MyProject is the root namespace.
The code I have is as follows, but I am getting an "Object reference not set to an instance of an object" error.
Protected Function LoadEmbeddedTemplate(ByVal EmbeddedFilename As String) As String
'NB - the EmbeddedFilename variable is passed as "MyProject.Templates.Text.TemplateFile.txt"
Dim f As Stream = System.Reflection.Assembly.GetEntryAssembly().GetManifestResourceStream(EmbeddedFilename)
Dim st As New StreamReader(f)