http://msdn.microsoft.com/zh-cn/library/system.resources.resxresourcereader.aspx

*在console程序下读到资源文件时使用到“ResXResourceReader ”光靠using还不行,需要在工程中引用System.Windows.Forms才可以使用

缺点:资源文件无法嵌入程序内部

 

代码
using System;
using System.Collections;
using System.Resources;
namespace ConsoleS2H
{
    class Program
    {
  
        static void Main(string[] args)
        {
            // Create a ResXResourceReader for the file items.resx.
            ResXResourceReader rsxr = new ResXResourceReader("address.resx");

            // Iterate through the resources and display the contents to the console.
            foreach (DictionaryEntry d in rsxr)
            {
                Console.WriteLine(d.Key.ToString() + ":\t" + d.Value.ToString()+":\t");
            }
            //Close the reader.
            rsxr.Close();
            Console.ReadLine();
        }
    }
}

 

 

posted on 2009-11-30 14:47  forrestsun  阅读(650)  评论(0编辑  收藏  举报