By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,887 Members | 1,214 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,887 IT Pros & Developers. It's quick & easy.

Save configuration and file format

P: n/a
Hi misters,

I have an app.config (UTF-8 format file). I create an application winforms
for changes and save configuration programatically.

When I save changes the format file changes to ANSI :( but I need format
file UTF-8, and too when I open app.config and changed it, Visual Studio
save it like UTF-8.

Any suggestions or comments, please ? I need help about it

Thanks in advance. See code below please

My code is:

string rutaConfig= tbRutaConfigServicioIndexado.Text;
// Map to the application configuration file.
ExeConfigurationFileMap configFile= New ExeConfigurationFileMap();
configFile.ExeConfigFilename = rutaConfig;
Configuration config=
ConfigurationManager.OpenMappedExeConfiguration(co nfigFile,
ConfigurationUserLevel.None);

string[] keys = config.AppSettings.Settings.AllKeys;

KeyValueConfigurationCollection settings1= config.AppSettings.Settings();

settings1("PDF_CREADOR").Value = tbServicioIndexadoPDF_CREADOR.Text;

config.ConnectionStrings.ConnectionStrings["SQLConnection"].ConnectionString
= tbCadenaConexionFirmasParaServicioIndexado.Text;

//' Modifica el app.config pero pierde los comentarios del appsettings
config.Save(ConfigurationSaveMode.Modified);
ServiceModelSectionGroup sectionGroup =
ServiceModelSectionGroup.GetSectionGroup(config);

ChannelEndpointElementCollection listaEndpoints =
sectionGroup.Client.Endpoints;

if (listaEndpoints.Count >= 2)
{
ChannelEndpointElement endpoint = null;
ChannelEndpointElement endpoint2 = null;

// Endpoint Agente Servicio Base
endpoint = BuscarEndpointClientePorNombre(listaEndpoints,
"AgenteServicioBase");
endpoint.Address = new Uri(endpointAgenteServicioBase);

// Endpoint Agente Log
endpoint2 = BuscarEndpointClientePorNombre(listaEndpoints,
"AgenteLog");
endpoint2.Address = new Uri(endpointAgenteLog);

}
config.Save(ConfigurationSaveMode.Modified);

--
http://www.alhambra-eidos.es/web2005/index.html
www.kiquenet.com/churrosoft
http://www.setbb.com/putainformatica...opic.php?p=843
www.trabajobasura.com/solusoft

Sep 25 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.