Hey. I added a text file in my project and set it as an embedded resource. How would I go about doing a 'msgbox' on everything that's in that text file?
Thanks
John
Printable View
Hey. I added a text file in my project and set it as an embedded resource. How would I go about doing a 'msgbox' on everything that's in that text file?
Thanks
John
VB Code:
Dim str As New IO.StreamReader(IO.File.OpenRead("FileName")) MessageBox.Show(str.ReadToEnd) str.Close()
Are you using VB 2005? Please specify in future.
hmm im using 2003. The thing is that the text file is an actual embedded resource. It's not on the computer, it's part of the project. I want the forum to be able to access it when it's all compiled into the .exe. This is kinda like accessing embedded pictures.
In VB 2005 it is so easy a retarded lump of coal could do it. You add the file as a resource on the Resources tab of the project properties and at run time you do this:In earler versions you have to work a bit harder.VB Code:
Dim fileContents As String = My.Resources.ResourceNameThat code is adapted from this example. I used a project named WindowsApplication4 and a file named StackTrace.txt. You'll obviously have to change those to whatever is appropriate in your case.VB Code:
Dim thisExe As System.Reflection.Assembly thisExe = System.Reflection.Assembly.GetExecutingAssembly() Dim file As System.IO.Stream = _ thisExe.GetManifestResourceStream("WindowsApplication4.StackTrace.txt") Dim sr As New IO.StreamReader(file) MessageBox.Show(sr.ReadToEnd()) sr.Close()