简体   繁体   中英

how to add files to the project namespace in visual studio?

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

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.

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM