[英]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. 第1步:添加现有项目菜单。
Step 2:Then browsing to the file that i want to add and simply adding it. 步骤2:然后浏览到我要添加的文件,然后简单地添加它。
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. 我在myStream中得到null。 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 Madhup Rregards
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. 您可以使用
GetManifestResourceNames
来检查可用的内容。
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).
通过在解决方案资源管理器中选择文件,然后转到属性窗口(F4),可以找到此属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.