473,396 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 3842
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.Configuration 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.com

"Christian Muggli" <christian.muggliATgmail.comwrote in message
news:55**********************************@microsof t.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.Configuration 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
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...
7
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...
13
by: invincible | last post by:
hi friends , how can I declare / create function during runtime similiar to lambda in lisp. thanks Mohan
7
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...
1
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...
6
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...
8
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...
1
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...
1
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....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.