473,785 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Save configuration and file format

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= tbRutaConfigSer vicioIndexado.T ext;
// Map to the application configuration file.
ExeConfiguratio nFileMap configFile= New ExeConfiguratio nFileMap();
configFile.ExeC onfigFilename = rutaConfig;
Configuration config=
ConfigurationMa nager.OpenMappe dExeConfigurati on(configFile,
ConfigurationUs erLevel.None);

string[] keys = config.AppSetti ngs.Settings.Al lKeys;

KeyValueConfigu rationCollectio n settings1= config.AppSetti ngs.Settings();

settings1("PDF_ CREADOR").Value = tbServicioIndex adoPDF_CREADOR. Text;

config.Connecti onStrings.Conne ctionStrings["SQLConnect ion"].ConnectionStri ng
= tbCadenaConexio nFirmasParaServ icioIndexado.Te xt;

//' Modifica el app.config pero pierde los comentarios del appsettings
config.Save(Con figurationSaveM ode.Modified);
ServiceModelSec tionGroup sectionGroup =
ServiceModelSec tionGroup.GetSe ctionGroup(conf ig);

ChannelEndpoint ElementCollecti on listaEndpoints =
sectionGroup.Cl ient.Endpoints;

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

// Endpoint Agente Servicio Base
endpoint = BuscarEndpointC lientePorNombre (listaEndpoints ,
"AgenteServicio Base");
endpoint.Addres s = new Uri(endpointAge nteServicioBase );

// Endpoint Agente Log
endpoint2 = BuscarEndpointC lientePorNombre (listaEndpoints ,
"AgenteLog" );
endpoint2.Addre ss = new Uri(endpointAge nteLog);

}
config.Save(Con figurationSaveM ode.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
0 1646

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
11263
by: Maya | last post by:
Hey, there! I'm new to vb.net and it seems I wouldn't be able to solve this without help. I have a pipe delimited file that has to be saved in txt format so it could be accepted by my DTS package. If I open and save the file manualy in Wordpad - it works. (not in Notepad otherwise formatting is changed and DTS package won't accept it.)
1
5879
by: DraguVaso | last post by:
Hi, I found some examples for storing the FormSettings of a Form in an XML-file, but none of these could match my criteria: What I am looking for is the possibility to save the FormSettings of multiple Instances of 1 form. I have a Form frmSource from which I have multiple Instances, each with a unique Identifier. So when I Load or Close a specific instance, I want to load or save the Settings (Top, Height, Width, etc) in an XML-file....
0
2521
by: Andrzej Kaczmarczyk | last post by:
Hello, I am having troubles saving configuration file. I did the folloing: inherited from ConfigurationSection, ConfigurationCollection, ConfigurationElement to define my own element in config file. If I do the following:
0
3603
by: ssg31415926 | last post by:
I've been trying to save a hashtable in an Application Settings file. I need to save settings for each tabPage on a form. Trouble is, the number of tabPages is determined at runtime, so I can't have individual settings for each page. I decided to hold them in a collection. I started out with a generic Dictionary but that didn't work. So, I created a new Forms app to test it out and created a Settings file. It didn't offer me the...
1
6827
by: liuliuliu | last post by:
hi -- sorry if this is trivial -- but how do you make a screenshot of a pygame display? i have a surface which is basically the entire visible screen -- how do you write this surface as an image file during specific events in the script execution? image format doesnt matter. thanks! christine
1
15522
by: Shannon Richards | last post by:
Hello All: I have implemented a custom configuration section in my app.config file as follows: <configSections> <section name="AdminUIConfig" type="TestMgr.UIConfigSection,TestMgr"/> </configSections> <AdminUIConfig name="Admin" caption="Administrator" captionLC="administrator">
0
2090
by: =?Utf-8?B?Qy4gSHVnaGVz?= | last post by:
Hello, I have a .net 2.0 application using a 'Settings.settings' configuration file to store application settings. The settings are modified at runtime and stored when the user exits the application. Occasionaly, this exception will occur when calling the Settings.Default.Save() method: Invalid high surrogate character (0xDE1C). A high surrogate character must
2
3031
by: chike_oji | last post by:
Please can someone help me. I am writing a web application, that allows for the upload of an excel sheet into the database. I have an upload button and a save button. The upload button allows for the retrieval of the excel data into a DataTable, which is bound to a GridView for previewing before saving to the Database. But, whenever I click on the save button, I lose the DataTable's data, so I lose the data I want to save to the...
0
2623
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi, thanks, mister The code string rutaConfig = tbRutaConfigServicioBase.Text; '// Map to the application configuration file. ExeConfigurationFileMap configFile = New ExeConfigurationFileMap();
0
9483
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10346
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10157
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10096
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8982
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.