RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
如何从程序集中读取资源

首先使用反编译工具查看程序集中的资源

成都创新互联公司专注于吉木乃企业网站建设,成都响应式网站建设公司,商城网站定制开发。吉木乃网站建设公司,为吉木乃等地区提供建站服务。全流程按需制作网站,专业设计,全程项目跟踪,成都创新互联公司专业和态度为您提供的服务

如何从程序集中读取资源

代码如下:

Assembly myAssembly;
myAssembly = System.Reflection.Assembly.Load("SQLEditor2"); //不要加程序集扩展名
System.Resources.ResourceManager myManager = new System.Resources.ResourceManager("SQLEditor2.FrmEditor", myAssembly); //不要加.resources
var icon = (System.Drawing.Icon)myManager.GetObject("$this.Icon");
using (var f = File.Create("C:\\$this.Icon.ico"))
{
    icon.Save(f);
}
string[] bmpNames = new string[]{
                               "tsbsel.Image",
                               "toolStripButton1.Image",
                               "toolStripSplitButton1.Image"
                            };
System.Drawing.Image myImage;
foreach (string bmpName in bmpNames)
{
    myImage = (System.Drawing.Image)myManager.GetObject(bmpName);
    myImage.Save(String.Format("C:\\{0}.bmp", bmpName));
}

这样就可以得到程序集中的Icon和Bitmap了,string类型的内容直接从反编译工具中获得就可以了。


当前名称:如何从程序集中读取资源
链接分享:http://scyingshan.cn/article/jehsjo.html