views:

35

answers:

2

hi all,

i am having a problem in adding the image files to project namespace. I'm trying to do this like........

Step 1:Going to add existing item menu.

Step 2:Then browsing to the file that i want to add and simply adding it.

But when I'm trying to read this file by this method-------

Assembly myAssembly = Assembly.GetExecutingAssembly();
Stream myStream = myAssembly
        .GetManifestResourceStream("namespace.filename.fileExtension");
img = new Bitmap(myStream);

I get null in myStream. I think there is some other way to add files to the namespace of the project because previously I have added some files and the same method is working for those files.

Anybody knowing the answer please help.

Rregards, Madhup

+1  A: 

Have you marked those files to be an embedded resource (solution explorer)? Also - try it without the extension. You can use GetManifestResourceNames to check what is available.

Marc Gravell
thanks for the help. i found out this to be mine silly mistake that cost me one day of effort wasted. i wish i do no forget it again.
Madhup
A: 

I think that you need to set the compile-property of the file to 'embedded resource'. You find this propert by selecting th file in the solution explorer and then go to the properties window (F4).

Ruben
thanks for the help. i found out this to be mine silly mistake that cost me one day of effort wasted. i wish i do no forget it again.
Madhup