Click here to Skip to main content
15,919,613 members
Home / Discussions / C#
   

C#

 
GeneralRe: I'm becoming crazy about keys Pin
James T. Johnson20-Aug-02 6:19
James T. Johnson20-Aug-02 6:19 
QuestionAuto Tab? Pin
Johnny Zee16-Aug-02 5:32
sussJohnny Zee16-Aug-02 5:32 
AnswerRe: Auto Tab? Pin
leppie16-Aug-02 6:42
leppie16-Aug-02 6:42 
GeneralTo console or not to console... Pin
Ryan Cromwell16-Aug-02 3:20
Ryan Cromwell16-Aug-02 3:20 
GeneralRe: To console or not to console... Pin
Ryan Cromwell16-Aug-02 4:03
Ryan Cromwell16-Aug-02 4:03 
GeneralResources Pin
leppie16-Aug-02 0:48
leppie16-Aug-02 0:48 
GeneralRe: Resources Pin
Nnamdi Onyeyiri16-Aug-02 0:55
Nnamdi Onyeyiri16-Aug-02 0:55 
GeneralRe: Resources Pin
James T. Johnson16-Aug-02 1:32
James T. Johnson16-Aug-02 1:32 
Like Nnamdi said you can embed anything into the assembly Wink | ;)

If you have VS.NET it is very easy to do; add the file to your project, then in its properties set Build Type to "Embedded Resource".

To get it back out is simple, if you know the name of the object (and yes it is possible to get all of the names)

// First step, get the assembly that contains the resources
Type type = typeof(MyClassFromAssemblyWithResources);  ;P
Assembly asm = type.Assembly;
 
// With the assembly we can proceed to get a Stream 
// to the resource
Stream stream = asm.GetManifestResourceStream(name);
 
// Do something with the Stream
Now to get the names of the resources use this bit of code (real simple Smile | :) )

// First step, get the assembly that contains the resources
Type type = typeof(MyClassFromAssemblyWithResources);  ;P
Assembly asm = type.Assembly;
 
string [] names = asm.GetManifestResourceNames();
Done Smile | :)

Now, how is the name generated in VS.NET? First it takes the default namespace ("MyCompany.MyProduct"), then appends the names of any folders it is placed in within the project ("Resources"), finally it appends the filename of the resource ("MyResource.ext"). Given the above example the name would be MyCompany.MyProduct.Resources.MyResource.ext.

If you compile using the command line then you specify the name as the second argument to the /resource compiler switch.

I don't know how SharpDevelop derives its naming scheme.

James
"And we are all men; apart from the females." - Colin Davies
GeneralRe: Resources Pin
Nnamdi Onyeyiri16-Aug-02 1:49
Nnamdi Onyeyiri16-Aug-02 1:49 
GeneralRe: Resources Pin
James T. Johnson16-Aug-02 1:53
James T. Johnson16-Aug-02 1:53 
GeneralRe: Resources Pin
Nnamdi Onyeyiri16-Aug-02 2:52
Nnamdi Onyeyiri16-Aug-02 2:52 
GeneralRe: Resources Pin
leppie16-Aug-02 1:55
leppie16-Aug-02 1:55 
GeneralRe: Resources Pin
James T. Johnson16-Aug-02 2:14
James T. Johnson16-Aug-02 2:14 
GeneralRe: Resources Pin
leppie16-Aug-02 2:33
leppie16-Aug-02 2:33 
GeneralPainting Order Pin
albean15-Aug-02 20:41
albean15-Aug-02 20:41 
GeneralRe: Painting Order Pin
leppie16-Aug-02 3:09
leppie16-Aug-02 3:09 
GeneralRe: Painting Order Pin
albean16-Aug-02 5:12
albean16-Aug-02 5:12 
GeneralRe: Painting Order Pin
Nick Parker16-Aug-02 6:27
protectorNick Parker16-Aug-02 6:27 
GeneralRe: Painting Order Pin
albean16-Aug-02 6:40
albean16-Aug-02 6:40 
GeneralRe: Painting Order Pin
Nick Parker16-Aug-02 6:47
protectorNick Parker16-Aug-02 6:47 
GeneralRe: Painting Order Pin
albean16-Aug-02 7:16
albean16-Aug-02 7:16 
GeneralRe: Painting Order Pin
Russell Morris16-Aug-02 7:52
Russell Morris16-Aug-02 7:52 
GeneralDistributed App Pin
Eka15-Aug-02 19:42
Eka15-Aug-02 19:42 
GeneralRe: Distributed App Pin
Nnamdi Onyeyiri16-Aug-02 0:51
Nnamdi Onyeyiri16-Aug-02 0:51 
GeneralRe: Distributed App Pin
James T. Johnson16-Aug-02 1:42
James T. Johnson16-Aug-02 1:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.