[英]reading a resource using GetManifestResourceStream
I'm trying to read a binary file from a resource using 我正在尝试使用以下方法从资源读取二进制文件
Stream input = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
where resourceName is a string, containing the resource's filename. 其中resourceName是一个字符串,包含资源的文件名。 I'm getting a null object back. 我回来了一个空对象。 I tried the fully qualified path (eg "myAssemblyName.Properties.Resources." + resourceName) but that didn't work either. 我尝试了完全限定的路径(例如“ myAssemblyName.Properties.Resources。” + resourceName),但这也不起作用。
Am I missing something? 我想念什么吗?
Make sure your file is included in the project. 确保文件包含在项目中。 Make sure that the "Build Action" for your file is set to "Embedded Resource". 确保文件的“生成操作”设置为“嵌入式资源”。 Check what the name is with 检查名称与
Assembly.GetExecutingAssembly().GetManifestResourceNames()
Load the resource stream with 加载资源流
Assembly.GetExecutingAssembly().GetManifestResourceStream()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.