Resources的详情见http://www.csharpwin.com/dotnetspace/10957r3991.shtml

1.create

public static void Main()
{
ResourceWriter rw = new ResourceWriter("My.resources");
Icon ico = new Icon("Demo.ico");
Image canceloff = Image.FromFile("cancel-off.png"); rw.AddResource("demo.ico", ico); rw.AddResource("cancel-off.png", canceloff); rw.AddResource("MyStr", "从资源文件中读取字符串!");
rw.Generate();
rw.Close();
}

2.load

static Hashtable Load(string fileName)
{
if (File.Exists(fileName))
{
Hashtable resources = new Hashtable();
ResourceReader rr = new ResourceReader(fileName);
foreach (DictionaryEntry entry in rr)
{
resources.Add(entry.Key, entry.Value);
}
rr.Close();
return resources;
}
return null;
}

自己的一个例子:

  //写入资源文件内容
ResourceWriter rw = new ResourceWriter("My3.resources");
// Icon ico = new Icon("Demo.ico");
Image canceloff = Image.FromFile(@"D:\Documents\Visual Studio 2010\Projects\WebApplication1\ConsoleApplication1\bin\Debug\Application.png");
//rw.AddResource("demo.ico", ico);
rw.AddResource("Application.png", canceloff);
rw.AddResource("MyStr", "从资源文件中读取字符串!");
rw.Generate();
rw.Close(); //从资源文件里获取相应的数据
Hashtable ht =
Load(@"D:\Documents\Visual Studio 2010\Projects\WebApplication1\ConsoleApplication1\bin\Debug\My3.resources");
foreach (var VARIABLE in ht)
{
if((((System.Collections.DictionaryEntry)(VARIABLE)).Value).GetType().Name=="Bitmap")
{
Bitmap Bit = ((System.Collections.DictionaryEntry)(VARIABLE)).Value as Bitmap;
Bit.Save(@"D:\TEST.PNG", System.Drawing.Imaging.ImageFormat.Jpeg);
}
}

resource文件的更多相关文章

  1. 导出resource文件的的资源

    写个小工具,方便一次性将resource文件中的资源导出,不然反编译后一个个找,真是太麻烦了. using System;using System.Collections.Generic;using  ...

  2. IOS 从Resource文件夹下Copy文件到沙盒

    - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.t ...

  3. 如何在MVC的ActionLink中应用Resource文件

    项目中建立Resources文件夹. 添加Resource文件,必须添加一个默认的,其他语言可以添加很多个.我这里只添加了一个中文的. 双击每个资源文件,将Access Modifier 设置成pub ...

  4. maven项目中没有resource文件夹的问题

    之前使用eclipse创建maven项目,文件夹都是建好的,这几次创建,都没有resource文件夹,需要手动创建resource. 现象描述 在eclipse中,创建maven项目有两种方式: 一种 ...

  5. springboot 读取 resource文件

    文件位置信息如图: import java.io.IOException; import java.io.InputStream; import java.net.URLEncoder; import ...

  6. 遇到问题---java---myeclipse中maven项目引用另一个导致的resource文件混乱的问题

    遇到情况 情况是这样的,我们在构建项目时,经常会把一些公用的类和配置提取出去,作为一个公共项目.然后把公共项目作为一个jar包构件引入我们当前的项目中. 引入方式是 <dependency> ...

  7. 读取ClassPath下resource文件的正确姿势

    1.前言 为什么要写这篇文章?身为Java程序员你有没有过每次需要读取 ClassPath 下的资源文件的时候,都要去百度一下,然后看到下面的这种答案: Thread.currentThread(). ...

  8. Java读取resource文件/路径的几种方式

    方式一: String fileName = this.getClass().getClassLoader().getResource("文件名").getPath();//获取文 ...

  9. Android开发:《Gradle Recipes for Android》阅读笔记(翻译)3.3——整合resource文件

    问题: 想要在product的flavor里面改变图片,文字或者其它资源. 解决方案: 在flavor里面增加合适的资源目录,并且改变他们包含的值. 讨论: 考虑下3.2章的“hello world ...

随机推荐

  1. 前端工程精粹(一):静态资源版本更新与缓存(附精简js的工具)

    转自:http://www.infoq.com/cn/articles/front-end-engineering-and-performance-optimization-part1/ 每个参与过开 ...

  2. OpenWrt的开机启动服务(init scripts)

    参考 https://wiki.openwrt.org/doc/techref/initscripts 以一个简单的例子来说明 #!/bin/sh /etc/rc.common # Example s ...

  3. 那些遇到的position-fixed无效事件

    本篇文章由:http://xinpure.com/position-fixed-encountered-an-invalid-event/ 第一次无效事件 事件主角: transform 应用环境: ...

  4. 【LeetCode】35. Search Insert Position (2 solutions)

    Search Insert Position Given a sorted array and a target value, return the index if the target is fo ...

  5. Android开发之Service的远程调用

    在Andorid平台中,各个组件运行在自己的进程中,他们之间是不能相互访问的,但是在程序之间是不可避免的要传递一些对象,在进程之间相互通信.为了实现进程之间的相互通信,Andorid采用了一种轻量级的 ...

  6. Fusion Tables 图层用于呈现 Google Fusion Tables 中包含的数据

    Google Maps API 允许您使用 FusionTablesLayer 对象将 Google Fusion Tables 中包含的数据呈现为地图上的图层.Google Fusion Table ...

  7. Workflow_将一个消息同时发给通过用户(案例)

    2014-06-04 Created By BaoXinjian

  8. atcoder之A Great Alchemist

    C - A Great Alchemist Time limit : 2sec / Stack limit : 256MB / Memory limit : 256MB Problem Carol i ...

  9. 编码规范:Eclipse Code Templates设置

    现在的项目一般都是一个团队共同开发,而每个人都有自己的编码习惯,为了统一格式,项目组在项目开发之前都会制定一系列的规范.设置Code Templates的目的主要是为了统一各种注释的格式以及代码的模板 ...

  10. ECSHOP后台权限分配原理分析

    1.在权限管理->管理员列表,中添加一名管理员 2.在admin\includes\inc_menu.php $modules['02_cat_and_goods']['01_goods_lis ...