我想加載一個xml文檔Swedish.xml,它存在於我的解決方案中。我怎樣才能給路徑,該文件在Xamarin.android如何使用XDocument爲解決方案中的文本文件提供路徑?
我使用下面的代碼:
var text = File.ReadAllText("Languages/Swedish.txt");
Console.WriteLine("text: "+text);
但我得到異常消息:
Could not find a part of the path "//Languages/swedish.txt".
我甚至嘗試以下幾行:
var text = File.ReadAllText("./Languages/Swedish.txt");
var text = File.ReadAllText("./MyProject/Languages/Swedish.txt");
var text = File.ReadAllText("MyProject/Languages/Swedish.txt");
但他們都沒有工作。相同的例外信息正在出現。構建操作也被設置爲內容。路徑有什麼問題?提前致謝。
確實Swedish.xml嘗試有它的生成操作設置爲「內容」? – Jason
不,我現在做了,現在它的give目錄沒有發現異常。感謝幫助。但路徑有什麼問題? – Piscean