1.读取资源文件
ResourceManager resourceManager;
resourceManager = new ResourceManager(typeof(Form1).Namespace + ".res", Assembly.GetAssembly(typeof(Form1)));
ResourceSet resources = resourceManager.GetResourceSet(CultureInfo.CurrentCulture,true, true);
foreach
(DictionaryEntry de in resources)
{
...
}
2.写资源文件
IResourceWriter writer = new ResourceWriter("myResources.resources");
// Adds resources to the resource writer.
writer.AddResource("String 1", "First String");
writer.AddResource("String 2", "Second String");
writer.AddResource("String 3", "Third String");
// Writes the resources to the file or stream, and closes it.
writer.Close();
3.将图片作为资源文件
首先将图片设置为嵌入资源,如下图。
Icon logo;
Stream strm = this.GetType().Assembly.GetManifestResourceStream(typeof(Form1).Namespace +
”
.logo.ico");
if
(strm != null)
{
logo = new Icon(strm, 112,103);
}
return logo;