有谁懂c#.net里resource怎么用!!进来拿分!!!!

FollowIT 2006-05-29 02:27:19
有谁懂c#.net里resource怎么用!!
打开"解决方案资源管理器",右键,依次选择"添加\添加组件",在模板中选择"程序集资源文件",有谁会使用他,我要从这个资源文件中读取数据
...全文
974 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
FollowIT 2006-06-05
  • 打赏
  • 举报
回复
可参考:
http://blog.csdn.net/FollowIT/archive/2006/06/02/769816.aspx
ProjectDD 2006-06-04
  • 打赏
  • 举报
回复
直接打开它的视图界面...你添加,新建,文件.然后可以访问它们,就这样用啊

Propertys.Resource.FileName
NogamesNow 2006-06-03
  • 打赏
  • 举报
回复
mark
FollowIT 2006-06-02
  • 打赏
  • 举报
回复
我已解决
ResourceWriter rw = new ResourceWriter("mytest.resources");
rw.AddResource("test_2","今天六一儿童节!");
rw.Generate();
rw.Close();
ResourceManager rm = ResourceManager.CreateFileBasedResourceManager(Server.MapPath("../mytest"),".",null);
this.Label.Text=rm.GetString("test_2");
FollowIT 2006-05-29
  • 打赏
  • 举报
回复
zlz_212() 提供的
http://bin270.blogchina.com/4943605.html
正是我现在所采用的,但是要编译,使.txt--->.resource文件,有些麻烦,所以想寻求直接插入的方法,当打开"解决方案资源管理器",右键,依次选择"添加\添加组件",在模板中选择"程序集资源文件",我要从这个资源文件中直接读取数据,不用编译了,八仙过海,解决问题者高分奉上!
lowtemper 2006-05-29
  • 打赏
  • 举报
回复
写resource:
using System;
using System.Resources;


public class WriteResources {
public static void Main(string[] args) {

// Creates a resource writer.
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();
}
}

读resource:
using System;
using System.Resources;
using System.Collections;

public class ReadResources {

public static void Main(string[] args) {

// Opens a resource reader and gets an enumerator from it.
IResourceReader reader = new ResourceReader("myResources.resources");
IDictionaryEnumerator en = reader.GetEnumerator();

// Goes through the enumerator, printing out the key and value pairs.
while (en.MoveNext()) {
Console.WriteLine();
Console.WriteLine("Name: {0}", en.Key);
Console.WriteLine("Value: {0}", en.Value);
}
reader.Close();
}
}
zlz_212 2006-05-29
  • 打赏
  • 举报
回复
http://www0.ccidnet.com/tech/guide/2002/01/21/92_3939.html
http://www.daima.com.cn/Info/89/Info31054/
http://bin270.blogchina.com/4943605.html
FollowIT 2006-05-29
  • 打赏
  • 举报
回复
有无相关资料,我已经查了好久了
liujiwe79 2006-05-29
  • 打赏
  • 举报
回复
资源文件主要保存一些资源,可以通过代码读取资源的数据

110,566

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧