Ver Mensaje Individual
  #5 (permalink)  
Antiguo 25/07/2008, 07:23
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

da error, mi codigo final es este:

Cita:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;


namespace DivineRO_Suite_Server
{
public partial class Terminos_Legales : Form
{
public Terminos_Legales()
{
InitializeComponent();
}

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);
}

private void bacepto_Click(object sender, EventArgs e)
{
this.UpdateKey("AceptoTocs", "true");
Inicio inicioform = new Inicio();
inicioform.Show();
this.Close();
}
}
}
que puede ser?