473,657 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

create app.config during runtime from within code

can someone explain me how to create a app.config file during runtime? i see
two ways:

- add a skeleton of an app.config file to the exe/dll and extract it during
runtime as a resource and extract
OR
- create a app.config file using xml

is there another way?

thanks

christian

Dec 30 '07 #1
2 3861
Christian,

Well, if you really want to get rudimentary, you could create a
FileStream instance and write it byte by byte.

But I doubt you want to do that.

Usually, the configuration sections have object models that you can
access through the classes in the System.Configur ation namespace. You could
try working with these models in code and then persist them to another file
(although because config files are not written to, except for user setting
sections, it might be the case that there is not much support for going from
the config object to XML, only vice versa).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Christian Muggli" <christian.mugg liATgmail.comwr ote in message
news:55******** *************** ***********@mic rosoft.com...
can someone explain me how to create a app.config file during runtime? i
see two ways:

- add a skeleton of an app.config file to the exe/dll and extract it
during runtime as a resource and extract
OR
- create a app.config file using xml

is there another way?

thanks

christian
Dec 30 '07 #2
You could certainly keep a bare-bones config file as an embedded resource and
extract and save it next to the executable. You could also use the classes in
System.Configur ation to work with, edit and resave your modified config file.
But that's with the proviso that the app only loads an existing config file
one time - when it's first run. So you'd need some mechanism to force it to
be reloaded once modified, unless you plan on only having it take effect when
the application is restarted.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"Christian Muggli" wrote:
can someone explain me how to create a app.config file during runtime? i see
two ways:

- add a skeleton of an app.config file to the exe/dll and extract it during
runtime as a resource and extract
OR
- create a app.config file using xml

is there another way?

thanks

christian
Dec 30 '07 #3

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

Similar topics

16
4190
by: DraguVaso | last post by:
Hi, I have a Windows Service running (made in VB.NET), and wanted to be able to change from time to time some parameters by changing them in the App.config. But it seems that the application doesn't use the changed values in the App.config, but continue to use the values that were there during start-up. Is there a way to let the application use the new values in the App.config? Is there kind of some 'refresh' function that I should...
7
8850
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and save it to the user's machine. I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
13
4386
by: invincible | last post by:
hi friends , how can I declare / create function during runtime similiar to lambda in lisp. thanks Mohan
7
21151
by: A.M-SG | last post by:
Hi, We have a class library application that needs to read some application settings from it's own app.config file. I assume that a ClassLibrary.DLL can have a app.config file, but during
1
1577
by: Blue Man | last post by:
Anybody has idea how to save value in web.config file during runtime? ConfigurationSettings.AppSettings.Add("test","test value"); won't work, it will cause and error : the file is read only during rumtime.
6
3559
by: John Lau | last post by:
Hi, I am looking at the MS KB Article 306355: HOW TO: Create Custom Error Reporting Pages in ASP.NET by Using Visual C# .NET This article describes how to redirect errors to a custom html error page. All six steps in the article work just fine. Then at the end of the article, there is a little comment about redirecting errors to an aspx page (instead of an html page):
8
34623
by: Subra Mallampalli | last post by:
Hi, I am trying to use <runtime> section within the web.config file. However, the contents of the <runtime> section seem to be ignored. What am i missing here? Is <runtime> section not used by web apps? Any help is greatly appreciated. Thanks,
1
5882
by: pareptrc | last post by:
Dear all, I want to write a pdf file from crystal report in my web application. Here is my proc: Private Sub CreatePDFReport(ByVal KeyReference As String) Dim objReport As New ReportDocument() Dim diskOpts As New DiskFileDestinationOptions()
1
3311
by: Harold Howe | last post by:
When .NET loads an app.config at runtime (myapp.exe.config), will it honor an entity declaration? Based on what I am seeing, the answer is no, but I think, or hope, that I am doing something wrong. I tried this: // myapp.exe.config <?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE configuration >
0
8394
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8306
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
8732
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
6164
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
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4152
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
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.