我已經給了一個任務,爲我們的網站的靜態內容製作一個資源xml文件,以便我們可以查找該xml文件中針對特定id的內容並顯示它。例如,如果我們寫我們的主頁上「歡迎來到xyz.com」應該存儲在XML文件中像資源xml文件
<word>
<add Key="welcome" value="Welcome to xyz.com" />
</word>
<word>
<add key="key1" value="some other static content" />
</word>
,所以我們將能夠顯示由ID =「歡迎」的文本.. plz幫助。
訪問資源文件
string key = "Home";
string resourceValue = string.Empty;
string resourceFile = "Resource";//name of my resource file Resource.resx
string filePath =System.AppDomain.CurrentDomain.BaseDirectory.ToString();
ResourceManager resourceManager = ResourceManager.CreateFileBasedResourceManager(resourceFile, filePath, null);
resourceValue = resourceManager.GetString(key);
,並收到以下錯誤
Could not find any resources appropriate for the specified culture (or the neutral culture) on disk.
baseName: Resource locationInfo: <null> fileName: Resource.resources
你還沒有真正問過一個具體的問題。你有什麼麻煩? – 2010-11-04 07:12:07
研究在Visual Studio中使用資源(resx)文件。 – 2010-11-04 08:19:28
我不知道該怎麼做,我認爲生病必須使用XML讀取器,但具體到底是什麼? – Rafay 2010-11-04 09:31:40