使用Visual Studio 2010如何以编程方式枚举resx文件中的资源?
如何枚举位于我的程序集内部的特定资源文件(.resx)中的所有资源?
在我的项目中,我有一个带有3个文本文件(字符串资源)的Resources.resx文件。我需要列举这3个文件,然后用他们的名字来获取他们的内容。
谢谢。
使用Visual Studio 2010如何以编程方式枚举resx文件中的资源?
如何枚举位于我的程序集内部的特定资源文件(.resx)中的所有资源?
在我的项目中,我有一个带有3个文本文件(字符串资源)的Resources.resx文件。我需要列举这3个文件,然后用他们的名字来获取他们的内容。
谢谢。
看出:
Dim man As New ResourceManager("Discovery.Resources", Assembly.GetExecutingAssembly)
Dim resset As ResourceSet
resset = man.GetResourceSet(CultureInfo.CurrentCulture, True, True)
For Each item As DictionaryEntry In resset
Console.WriteLine(item.Key)
Next
使用ResXResourceReader从System.Windows.Forms
。
它枚举XML资源(的.resx) 文件和流,并读取 顺序资源名称和值 对
public static void Main()
{
// Create a ResXResourceReader for the file items.resx.
ResXResourceReader rsxr = new ResXResourceReader("items.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());
}
//Close the reader.
rsxr.Close();
}
嗨@Andrzej,但如何我可以这样做,如果resx文件在我的程序集内(在Visual Studio项目属性窗口中生成)? – RHaguiuda 2011-01-11 11:12:17