查找另一个程序集中的所有嵌入式资源 [英] Find all embedded resources in another assembly

查看:66
本文介绍了查找另一个程序集中的所有嵌入式资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的项目进行本地化。为此,我有一个类,该类应从另一个程序集中加载嵌入式资源,然后读出字符串。

I'm working on localization for my project. For this, I have a class which should load an embedded resource from another assembly, and then read out the strings.

但是我还需要知道该程序集的资源文件包含。
的数量和使用的语言是未知的。

But also I need to know which resource files this assembly contains. The number and which languages those are, is unknown.

那么我如何找出该程序集中 .resx文件的命名方式?
这些都具有相同的方案: de-DE.resx, en-US.resx,等等。

So how do I find out how the ".resx" file in this assembly is named? Those all have the same scheme: "de-DE.resx", "en-US.resx", and so on.

我需要知道这些程序集中包含多少个文件,
和它们是哪种语言。

I need to know how many of those files are contained in this assembly, and which languages they are.

我知道ResourceManager可以访问它们,因此应该也可以通过编程方式访问此信息...

I know that the ResourceManager has access to them, thus it should be possible to access this information programatically too...

推荐答案

您应使用 GetManifestResourceNames Assembly 类中的c>方法( msdn ):

You should use GetManifestResourceNames method from Assembly class (msdn):

string[] resourceNames = this.GetType().Assembly.GetManifestResourceNames();
foreach(string resourceName in resourceNames)
{
    Console.WriteLine(resourceName);
}

这篇关于查找另一个程序集中的所有嵌入式资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆