Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How To Use Embedded Resources?
Message
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB.NET 1.1
Miscellaneous
Thread ID:
01122006
Message ID:
01122250
Views:
21
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform