Ver Mensaje Individual
  #3 (permalink)  
Antiguo 25/07/2008, 07:04
felix46
 
Fecha de Ingreso: diciembre-2007
Mensajes: 107
Antigüedad: 17 años, 2 meses
Puntos: 4
Respuesta: C# -> App.config no puedo modificarlo desde el programa :S

disculpa como inserto este código en un boton?
Cita:
// Updates a key within the App.config

public void UpdateKey(string strKey, string newValue)
{
if (!KeyExists(strKey))
throw new ArgumentNullException("Key", "<" + strKey +
"> does not exist in the configuration. Update failed.");
XmlNode appSettingsNode =
xmlDoc.SelectSingleNode("configuration/appSettings");
// Attempt to locate the requested setting.

foreach (XmlNode childNode in appSettingsNode)
{
if (childNode.Attributes["key"].Value == strKey)
childNode.Attributes["value"].Value = newValue;
}
xmlDoc.Save(AppDomain.CurrentDomain.BaseDirectory +
"..\\..\\App.config");
xmlDoc.Save(AppDomain.CurrentDomain.SetupInformati on.ConfigurationFile);
}