>Ben,
>Add your text file to the project and make sure the
Build Action = Embedded Resource.
>The run the following code (might want to clean it up a little since it is pretty down and dirty):
>
>
>string myString;
>string myResource = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + ".MyTextFile.txt";
>using (Stream myStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(myResource))
>{
> using (StreamReader myReader = new StreamReader(myStream))
> {
> myString = myReader.ReadToEnd();
> }
>}
>
>MessageBox.Show(myString);
>
>
>Note: If your file was added to a folder within your project you need to include the folder information in the resource string.
>
>Hope this helps.
>
>Einar
Umm...how do I add the Folder Name "EmbeddedResources" in the Resource String? Here is the code I wrote, converted from your C# to VB.Net.
Dim strString As String
Dim strResource As String = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name & ".TextFile.txt"
Dim objStream As IO.Stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(strResource)
Dim objStreamReader As IO.StreamReader = New IO.StreamReader(objStream)
strString = objStreamReader.ReadToEnd
MessageBox.Show(strString)
________________________
Ben Santiago, MCP & A+
Programmer Analyst (SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS)
Eastern Suffolk BOCES - Student Data Services
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
-Rich Cook