Ola, pessoal estou com o seguinte problema tenho uma aplicação mobile feita em C# no VS2005 a qual quero utilizar um arquivo de configuração ja vira varios exemplo e dicas mas não esta dando certo na minha aplicação:
Abaixo segue codigo exemplo ao qual estou usando:
string
AppPath = Path
.GetDirectoryName(System.Reflection.
Assembly
.GetExecutingAssembly().GetName().CodeBase);
string
ConfigFile = Path
.Combine(AppPath, "App.config"
);
if
(
File .Exists(ConfigFile) ==
false
)
{
System.Windows.Forms. MessageBox
.Show(
"Config file does not exist"
);
return
;
}
XmlDocument
oXml = new
XmlDocument
();
oXml.Load(ConfigFile); -------->>>>>>>>>>> o erro esta nessa LINHA
XmlNodeList
oList = oXml.GetElementsByTagName(
"appSettings"
);
AppSettings = new
NameValueCollection
();
foreach
(
XmlNode oNode
in
oList)
{
foreach
(
XmlNode oKey
in
oNode.ChildNodes)
{
AppSettings.Add(oKey.Attributes[
"key"
].Value, oKey.Attributes[
"value" ].Value);
}
}
System.Windows.Forms.
MessageBox
.Show(AppSettings[
"Item1" ]);
Junior