惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
G
Google Developers Blog
V
V2EX
美团技术团队
H
Help Net Security
月光博客
月光博客
爱范儿
爱范儿
Engineering at Meta
Engineering at Meta
The Cloudflare Blog
U
Unit 42
大猫的无限游戏
大猫的无限游戏
Recent Announcements
Recent Announcements
A
About on SuperTechFans
博客园 - Franky
The GitHub Blog
The GitHub Blog
N
Netflix TechBlog - Medium
人人都是产品经理
人人都是产品经理
博客园 - 司徒正美
MyScale Blog
MyScale Blog
B
Blog
雷峰网
雷峰网
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
T
The Blog of Author Tim Ferriss

博客园 - nametmp

异步调用过程 Winform用匿名方法新建线程的方法 enum枚举用法笔记 对C#委托的理解 对using的新认识 视频文件信息读取器 琐碎记录 【转贴】GridView里面的HYPERLINK数据邦定 【转贴】数据邦定语法 - nametmp - 博客园 TableAdapter、Dataset与BindingSource的关系 webform 可视化在gridview中加入其它控件 WinForm 加入登陆窗体(c#) winform 中的 datagridview 添加 progressbar列 和 calendar 列 远程删除Kaspersky(被Kaspersky搞了一天) SqlServer2000登陆角色的具体权限 终于用sqlcmd连上sqlserver2005express了 sqlserver操作摘录 [转]SQL Server 2005中的SQLCMD工具使用 [转]sqlserver2005(Express版)的配置
【转】Resource与Resx的区别 - nametmp - 博客园
nametmp · 2010-12-03 · via 博客园 - nametmp

ResourceWriter生成二进制资源文件,文件的后缀名为.resources,而ResxResourceWriter编写生成基于XML的资源文件,文件的后缀名为.resx

1、  生成资源文件

//Bin目录下生成名为demo.resx的资源文件

ResXResourceWriter rrw = new ResXResourceWriter("demo.resx");

Image image = Image.FromFile(@"F:\Personal\Icons\WebIcon\webicon\001.gif");

rrw.AddResource("ApplicationTitle", "欢迎来到我的应用程序");

rrw.AddResource("testimage", image);

rrw.Generate();

rrw.Close();

//Bin目录下生成名为demo.resources的资源文件

ResourceWriter rw = new ResourceWriter("demo.resources");

Image image = Image.FromFile(@"F:\Personal\Icons\WebIcon\webicon\001.gif");

rw.AddResource("ApplicationTitle", "欢迎来到我的应用程序");

rw.AddResource("testimage", image);

rw.Generate();

rw.Close();

2、  将资源文件添加到工程中,类型为"嵌入的资源"

3、  读取嵌入式资源

// WindowsApplication1是类的名称空间,demo是资源的文件名

ResourceManager rm = new ResourceManager("WindowsApplication1.demo", this.GetType().Assembly);

string test = rm.GetString("ApplicationTitle").ToString();

Image image = (Image)rm.GetObject("testimage");

this.pictureBox1.Image = image;

// demo是资源的文件名

ResourceManager rm = new ResourceManager("demo", this.GetType().Assembly);

string test = rm.GetString("ApplicationTitle").ToString();

Image image = (Image)rm.GetObject("testimage");

this.pictureBox1.Image = image;

更复杂的资源文件,参考“如何在C#中使用内嵌资源文件”:http://www.csdn.net/develop/read_article.asp?id=15571