application config file

  • Thread starter Miha Markic [MVP C#]
  • Start date
M

Miha Markic [MVP C#]

Hi Ann,

There is no such support.
However, you might editi it like any other xml file.
2nd however, since the config file is normally placed under "program files"
folder which is very much protected against writting (only admin should have
write access) it might be impossible for a non-admin to alter the config
file.
 
A

Ann Marinas

Hi, all!

I have a question regarding application config files.

Is there a possibility that a value from the application config file can be
altered within the application itself?

If so, how is is possible?

thanks! :)
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi Ann,

No, you can't you have two options:

1- create your own config file , either XML or text and store there your
values, another way of doing it is using a Hashtable or NameValueCollection
and serialize it.

2- Keep the values in the registry

Hope this help,

Cheers,
 
K

Kyril Magnos

Hi Ann,

In addition to what Miha had replied with, I found this thread that might be
of some assistance. I'm not sure if this is exactly what you want to do, but
it might be helpful.

http://www.dotnet247.com/247reference/msgs/49/245285.aspx

What I usually do is create a ConfigSection and then deserialize it to a
class that implements System.Configuration.IConfigurationSectionHandler.
Then, when I want to update values to it, I update the class values.
Finally, I have the AppDomain.CurrentDomain.ProcessExit (you could also use
the Application.Exit or Application.ThreadExit events) wired up so that when
the application is about to exit, I serialize the running values in my class
back to the configuration file. It's not elegant, but it works and allows
for app options to be changed without the user having to restart the
application.

--
HTH

Kyril Magnos
"I'm not a developer anymore, I'm a software engineer now!" :)

| Hi, all!
|
| I have a question regarding application config files.
|
| Is there a possibility that a value from the application config file can
be
| altered within the application itself?
|
| If so, how is is possible?
|
| thanks! :)
|
|
 
A

Ann Marinas

Thanks Miha for answering my question.

I really do appreciate it! :)

Ann


Miha Markic said:
Hi Ann,

There is no such support.
However, you might editi it like any other xml file.
2nd however, since the config file is normally placed under "program files"
folder which is very much protected against writting (only admin should have
write access) it might be impossible for a non-admin to alter the config
file.


--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Ann Marinas said:
Hi, all!

I have a question regarding application config files.

Is there a possibility that a value from the application config file can be
altered within the application itself?

If so, how is is possible?

thanks! :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top