Click here to Skip to main content
15,890,512 members
Home / Discussions / C#
   

C#

 
GeneralRe: Selecting from listbox with right mouse button Pin
Schnemar6-Mar-02 23:28
Schnemar6-Mar-02 23:28 
GeneralAccessing Word Documents in C# Pin
1-Mar-02 8:41
suss1-Mar-02 8:41 
GeneralViewing Web Site Details Pin
Gavin_Mannion1-Mar-02 3:26
Gavin_Mannion1-Mar-02 3:26 
Generalmessages Pin
W_B1-Mar-02 1:07
W_B1-Mar-02 1:07 
GeneralRe: messages Pin
James T. Johnson1-Mar-02 14:36
James T. Johnson1-Mar-02 14:36 
GeneralRe: messages Pin
W_B3-Mar-02 22:40
W_B3-Mar-02 22:40 
Generalresource files in VS .NET Pin
Senkwe Chanda27-Feb-02 22:42
Senkwe Chanda27-Feb-02 22:42 
GeneralRe: resource files in VS .NET Pin
James T. Johnson28-Feb-02 5:00
James T. Johnson28-Feb-02 5:00 
Senkwe Chanda wrote:
Hi guys, simple question, how do you use resource files in C#? For example, suppose I create an icon using the editor in VS .NET and the file is named icon1.ico, how would I the go about referencing that file from my code?

In VS.NET click on your icon in the Solution Explorer then in the properties box change the Build Action to "Embedded Resource".

Now when you build your project you can get a stream to the file from the assembly.

System.Reflection.Assembly asm = GetType().Assembly;
System.IO.Stream = asm.GetManifestResourceStream("myDefaultNamespace.myFolder.Icon1.ico"));
The string that is passed in is a tad difficult to understand at first.

myDefaultNamespace is the namespace that is assigned by default to new classes that are added to your project. You can see what this is by going into the properties for your project.

If you create a folder within your project and place icons in there, then you also append the folder names to the namespace (if you haven't noticed it -- when you create a folder, any classes created inside that folder have the folder name appended to the default namespace); finally append the filename.

In the example above i have an icon named Icon1.ico located in a folder called myFolder in my project with a default namespace of myDefaultNamespace.

It is possible to set the default namespace to nothing, in which case you use the folder (if any) and the filename.

HTH,

James

Sonork ID: 100.11138 - Hasaki
"My words but a whisper -- your deafness a SHOUT.
I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972

QuestionHow to open a new window?? Pin
27-Feb-02 19:16
suss27-Feb-02 19:16 
GeneralLock a column in datagrid Pin
paulb26-Feb-02 11:45
paulb26-Feb-02 11:45 
QuestionHow to make custom/own BASE classes Pin
Felix Nielsen25-Feb-02 7:00
Felix Nielsen25-Feb-02 7:00 
AnswerRe: How to make custom/own BASE classes Pin
James T. Johnson25-Feb-02 7:48
James T. Johnson25-Feb-02 7:48 
GeneralRe: How to make custom/own BASE classes Pin
Felix Nielsen26-Feb-02 2:56
Felix Nielsen26-Feb-02 2:56 
GeneralRe: How to make custom/own BASE classes Pin
James T. Johnson26-Feb-02 11:05
James T. Johnson26-Feb-02 11:05 
GeneralRegistry Pin
BLaZiNiX25-Feb-02 6:34
BLaZiNiX25-Feb-02 6:34 
Generalquestions about C# Pin
Aaron T.25-Feb-02 4:40
Aaron T.25-Feb-02 4:40 
GeneralRe: questions about C# Pin
Anders Molin26-Feb-02 2:57
professionalAnders Molin26-Feb-02 2:57 
GeneralRe: questions about C# Pin
Aaron T.27-Feb-02 3:23
Aaron T.27-Feb-02 3:23 
GeneralPackage Application Pin
Gavin_Mannion25-Feb-02 4:11
Gavin_Mannion25-Feb-02 4:11 
GeneralRe: Package Application Pin
Cliff Dabrowski25-Feb-02 4:47
Cliff Dabrowski25-Feb-02 4:47 
GeneralRe: Package Application Pin
Gavin_Mannion25-Feb-02 22:00
Gavin_Mannion25-Feb-02 22:00 
GeneralRe: Package Application Pin
26-Feb-02 13:17
suss26-Feb-02 13:17 
GeneralRe: Package Application Pin
Gavin_Mannion26-Feb-02 21:56
Gavin_Mannion26-Feb-02 21:56 
GeneralInherit 2 classes in c# Pin
thongkk24-Feb-02 14:39
thongkk24-Feb-02 14:39 
GeneralRe: Inherit 2 classes in c# Pin
Tom Archer24-Feb-02 15:31
Tom Archer24-Feb-02 15:31 

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.