can I embed my own object, for example a table, into resource asse

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

If I do not want depend on file and want embed some data into resource
assembly which is not something predefined like bmp, icon...

Can I do that?
 
Just include the file containing your table (or whatever) in the project,
then on the properties tab set "Build Action" to "Embedded Resource".

You can then use something like this to access your file as a stream:

Assembly ass = Assembly.GetExecutingAssembly();
string[] resourceNames = ass.GetManifestResourceNames();
foreach (string resourceName in resourceNames)
{
if (resourceName.ToLower().EndsWith(".xml")) // or whatever
{
Stream resourceStream = ass.GetManifestResourceStream(resourceName);
....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top