如何从程序集中读取资源
首先使用反编译工具查看程序集中的资源
代码如下:
Assembly myAssembly;myAssembly = System.Reflection.Assembly.Load("SQLEditor2"); //不要加程序集扩展名System.Resources.ResourceManager myManager = new System.Resources.ResourceManager("SQLEditor2.FrmEditor", myAssembly); //不要加.resourcesvar 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类型的内容直接从反编译工具中获得就可以了。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。