Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically Add Resource

Status
Not open for further replies.

JurkMonkey

Programmer
Nov 23, 2004
1,731
CA
Does anyone know how to add a resource to a project during runtime?

I want to imbed a file in my project that is chosen by the user.

Thanks
-D
 
- instantiate a ResourceWriter object.
- open the resource file in which to add
- call AddResource() to add a string or an object to a resource file
- call Close();
Code:
FileStream fs = new FileStream("myassembly.resources", 
        FileMode.Append,FileAccess.Write);
 IResourceWriter rw = new ResourceWriter (fs);
    
     wr.AddResource("Thank", "Merçi!");
     Bitmap bmp = new Bitmap("myfile.jpg");
     wr.AddResource("Bmp", bmp);
     wr.Close();
obislavu
 
FileStream fs = new FileStream("myassembly.resources",
FileMode.Append,FileAccess.Write);


Please explain myassembly.resources

Thanks
 
For example, if your assembly MyApp has two forms , Form1, Form2 then:
Code:
string [] resnames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
will give the followings resnames:
"MyApp.Form1.resources"
and
"MyApp.Form2.resources"
obislavu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top