有谁懂c#.net里resource怎么用!!
打开"解决方案资源管理器",右键,依次选择"添加\添加组件",在模板中选择"程序集资源文件",有谁会使用他,我要从这个资源文件中读取数据

解决方案 »

  1.   

    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
      

  2.   

    写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();
       }
    }
      

  3.   

    zlz_212() 提供的
    http://bin270.blogchina.com/4943605.html
    正是我现在所采用的,但是要编译,使.txt--->.resource文件,有些麻烦,所以想寻求直接插入的方法,当打开"解决方案资源管理器",右键,依次选择"添加\添加组件",在模板中选择"程序集资源文件",我要从这个资源文件中直接读取数据,不用编译了,八仙过海,解决问题者高分奉上!
      

  4.   

    我已解决
    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");
      

  5.   

    直接打开它的视图界面...你添加,新建,文件.然后可以访问它们,就这样用啊Propertys.Resource.FileName
      

  6.   

    可参考:
    http://blog.csdn.net/FollowIT/archive/2006/06/02/769816.aspx