0
"App_LocalResources"の下に保存されている現在のページのResXファイルが必要です。App_LocalResourcesの下にあるResxファイルをロードしてそれを反復する方法
私はそれを繰り返す必要があります。
メソッド "GetLocalResourceObject"は、その時点で1つのキーにしかアクセスできません。
"App_LocalResources"の下に保存されている現在のページのResXファイルが必要です。App_LocalResourcesの下にあるResxファイルをロードしてそれを反復する方法
私はそれを繰り返す必要があります。
メソッド "GetLocalResourceObject"は、その時点で1つのキーにしかアクセスできません。
resx
ファイルには、ループ別のオプションは、ResXResourceReader
であるXElement
string resxFile = Server.MapPath("/App_LocalResources/Default.aspx.resx");
foreach (XElement element in XElement.Load(resxFile).Elements("data"))
{
string currentItem = string.Format("Key: {0} Value: {1}", element.Attribute("name").Value, element.Element("value").Value);
}
を持つすべての要素をすることができ、xmlファイル以外の何ものでもありませんので。ただし、プロジェクトへの参照としてSystem.Windows.Forms
を追加する必要があります。
using System.Resources;
//define the filename and path for the resx file
string resxFile = Server.MapPath("/App_LocalResources/Default.aspx.resx");
//load the file into the reader
using (ResXResourceReader reader = new ResXResourceReader(resxFile))
{
//loop all the entries
foreach (DictionaryEntry entry in reader)
{
string currentItem = string.Format("Key: {0} Value: {1}", entry.Key, entry.Value);
}
}