2017-04-11 3 views

答えて

0

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); 
    } 
} 
関連する問題