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

推荐订阅源

Vercel News
Vercel News
Recorded Future
Recorded Future
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Google DeepMind News
Google DeepMind News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
M
MIT News - Artificial intelligence
云风的 BLOG
云风的 BLOG
Y
Y Combinator Blog
N
News | PayPal Newsroom
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Help Net Security
Help Net Security
博客园 - Franky
SecWiki News
SecWiki News
Recent Announcements
Recent Announcements
T
Troy Hunt's Blog
The Register - Security
The Register - Security
The Last Watchdog
The Last Watchdog
Webroot Blog
Webroot Blog
S
Security Affairs
博客园 - 司徒正美
S
Schneier on Security
I
InfoQ
博客园_首页
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Threat Research - Cisco Blogs
Forbes - Security
Forbes - Security
腾讯CDC
N
Netflix TechBlog - Medium
N
News and Events Feed by Topic
Cloudbric
Cloudbric
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
A
About on SuperTechFans
Engineering at Meta
Engineering at Meta
Recent Commits to openclaw:main
Recent Commits to openclaw:main
B
Blog
V
Vulnerabilities – Threatpost
C
Check Point Blog
Google DeepMind News
Google DeepMind News
Google Online Security Blog
Google Online Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Hacker News - Newest:
Hacker News - Newest: "LLM"
C
Cisco Blogs
Schneier on Security
Schneier on Security
O
OpenAI News
K
Kaspersky official blog

博客园 - rex.ying

ASP.NET+Win2003虚拟主机安全设置 Windows2003服务器安全配置详细篇 - rex.ying - 博客园 mssql 日期格式化函数 devexpress报表控件的使用 关闭wscript.shell VS2005网站和SQL一起打包部署安装心得【转载】 怎样制作VS2008.NET应用程序的安装包 Developer Express XtraGrid使用技巧 UltraGrid文章收集 QQ2009聊天记录破解思路 InstallShield集成.net Framework的安装包制作 导出EXCEL后去除单元格前置的单引号 从SQL Server中导入/导出 Excel 的基本方法 通过远程桌面操作程序出现hook cannot be created(SendKeys语句错误)的解决 ASP.NET自定义控件事件响应 C# 获取任意窗体选中文字 屏幕取词 在 ASP.NET 中执行 URL 重写 仿Google的输入下拉提示框 xtrareport的使用心得(转)
用独立的DLL来存储图片(资源文件)
rex.ying · 2010-03-08 · via 博客园 - rex.ying

    使用独立的DLL来存储图片,可以把我们要用的图片文件全放在一个DLL当中,这样工程当中就只没有那么多的图片文件了。 1.在解决方案里添加一个新的class工程PicResource,然后把图片文件夹skin复制到工程目录下,并把skin包含在工程中;

2.在刚才新建的工程里选中skin文件夹下的所有图片,在property中改变 Build Action 属性为 Embedded Resource;

3.编译工程会产生一个PicResource.dll

4.在解决方案里添加一个测试用的windowsapplication工程winAppDemo1; 把刚才得到的PicResource.dll复制到winAppDemo1\bin\Debug下; 5.在测试工程里的form上添加一个Button一个picturebox 资源路径: <namespace>.<subfolders>.<image name>.<extension>(<命名空间>.<文件夹>.<图片名>.<后缀>) 代码: private void button1_Click(object sender, EventArgs e)

{

   Assembly myAssembly = Assembly.LoadFrom("PicResource.dll");

  Stream myStream = myAssembly.GetManifestResourceStream("PicResource.skin.right.bmp");

  Bitmap bmp = new Bitmap( myStream ); pictureBox1.Image = bmp;

}

如果点完button1在picturebox里能看到图片,OK,成功了

如果放在项目->Properties.Resources.resx文件则用:

C# code

Image img = (Image)命名空间.Properties.Resources.资源名;

  对外使用就将Resources.resx所有[资源]定义为public

如果放在cs文件对应*.resx文件则用:

C# code

Image img = ((Image)(new ComponentResourceManager(typeof(类名)).GetObject("控件名.属性名")));