我需要在后面的代码中读取整个resx文件。我是这样做的:
ResXResourceReader rsxrOrganizationSubtypes = new ResXResourceReader(@"D:\DNN_Cafaas\DesktopModules\OPEGIEKA.DNN.Modules.CreateInstitution\App_LocalResources\OrganizationSubtypes.resx");
rsxrOrganizationSubtypes.UseResXDataNodes = true;
IDictionaryEnumerator dict = rsxrOrganizationSubtypes.GetEnumerator();
while (dict.MoveNext())
{
ResXDataNode node = (ResXDataNode)dict.Value;
}
是否有可能从resx文件中排序/排序结果?例如,通过名字?
已解决(按resx文件中的值排序)。也许有更好的方法,但它的工作:
ResXResourceReader rsxr = new ResXResourceReader(PathToResX);
rsxr.UseResXDataNodes = true;
IDictionaryEnumerator dictRSXR = rsxr.GetEnumerator();
SortedDictionary<string, string> sortedRSXR = new SortedDictionary<string, string>();
while (dictRSXR.MoveNext())
{
ResXDataNode node = (ResXDataNode)dictRSXR.Value;
sortedRSXR.Add(node.GetValue((ITypeResolutionService)null).ToString(), node.Name);
}
foreach (KeyValuePair<string, string> p in sortedRSXR)
{
counterDDL++;
dropDownList.Items.Insert(counterDDL, new ListItem(p.Key, p.Value));
}
答案 0 :(得分:1)
您可以在while循环中向SortedDictionary<string, ResXDataNode>
添加键和值。这应该自动对您的条目进行排序。