将二进制文件嵌入类库中 [英] Embedding a binary file inside a class library

查看:56
本文介绍了将二进制文件嵌入类库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将自定义二进制文件嵌入C#类库中,然后在运行时使用二进制读取器读取它?

Is it possible to embed a custom binary file inside a C# class library and then at runtime read it with a binary reader?

我猜可能通过资源是有可能的.

I'm guessing it might be possible through resources.

非常感谢

推荐答案

您可以通过通过项目属性将文件添加到资源"中来实现.然后,Visual Studio将使用以下代码为您提供方便的类来访问文件

You can do this by adding the file to the Resources through the project properties. Visual studio will then give you a handy class to access your file using the following code

byte[] theFile = myNamespace.Properties.Resources.theBinaryFile;

资源名称为BinaryFile.

Where the resource name is theBinaryFile.

这篇关于将二进制文件嵌入类库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆