【发布时间】:2011-11-16 20:56:35
【问题描述】:
我有一个单独的应用程序(用于对我的 .resx 文件进行拼写检查),它作为预构建事件运行。但是,如果 .resx 文件包含文本文件(例如 xml),我的应用程序将加载该文件并尝试对其进行拼写检查。这不是我真正想要的。有没有办法从 ResXResourceReader 判断加载的资源是否实际上是一个文件?
代码示例如下所示:
ResXResourceReader reader = new ResXResourceReader(filename);
ResourceSet resourceset = new ResourceSet(reader);
Dictionary<DictionaryEntry, object> newvalues = new Dictionary<DictionaryEntry, object>();
foreach (DictionaryEntry entry in resourceset)
{
//Figure out in this 'if' if it is an embedded file and should be ignored.
if (entry.Key.ToString().StartsWith(">>") || !(entry.Value is string) || string.Compare((string)entry.Value, "---") == 0)
continue;
}
【问题讨论】: