如何从程序集中读取资源-成都快上网建站

如何从程序集中读取资源

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

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

如何从程序集中读取资源

代码如下:

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://kswjz.com/article/jehsjo.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流