473,386 Members | 1,823 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,386 software developers and data experts.

Writing to app.config

Hi, I've spent some time looking at articles about this but I can't
get it to work. I'm trying to write to my app.config file in .Net 2.0
using:

Configuration config =
ConfigurationManager.OpenExeConfiguration(Configur ationUserLevel.None);
config.AppSettings.Settings["email"].Value = "ry**@test.com";
config.Save(ConfigurationSaveMode.Minimal, true);

I get the message "Attempting to perform an unauthorized operation".
This is going to be a single user application with full write access
to the executable's path.

Thanks in advance.

Ryan
Dec 7 '07 #1
3 4609
On 7 Dec, 10:37, "ryanbreaksp...@norubbishgmail.com"
<ryanbreaksp...@gmail.comwrote:
Hi, I've spent some time looking at articles about this but I can't
get it to work. I'm trying to write to my app.config file in .Net 2.0
using:

Configuration config =
ConfigurationManager.OpenExeConfiguration(Configur ationUserLevel.None);
config.AppSettings.Settings["email"].Value = "r...@test.com";
config.Save(ConfigurationSaveMode.Minimal, true);

I get the message "Attempting to perform an unauthorized operation".
This is going to be a single user application with full write access
to the executable's path.

Thanks in advance.

Ryan
Interestingly, this works on a local drive. The LocalIntranet Zone
settings are set up to FullTrust, and I can read/write to other files
in the same location from within the application.

Any ideas?

Ryan
Dec 7 '07 #2
ry************@norubbishgmail.com wrote:
Hi, I've spent some time looking at articles about this but I can't
get it to work. I'm trying to write to my app.config file in .Net 2.0
using:

Configuration config =
ConfigurationManager.OpenExeConfiguration(Configur ationUserLevel.None);
config.AppSettings.Settings["email"].Value = "ry**@test.com";
config.Save(ConfigurationSaveMode.Minimal, true);

I get the message "Attempting to perform an unauthorized operation".
This is going to be a single user application with full write access
to the executable's path.

Thanks in advance.

Ryan
Why are you trying to do that?
Can't you use user settings instead which will be saved somewhere else?

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/
Dec 7 '07 #3
On 7 Dec, 13:53, Lasse Vågsæther Karlsen <la...@vkarlsen.nowrote:
ryanbreaksp...@norubbishgmail.com wrote:
Hi, I've spent some time looking at articles about this but I can't
get it to work. I'm trying to write to my app.config file in .Net 2.0
using:
Configuration config =
ConfigurationManager.OpenExeConfiguration(Configur ationUserLevel.None);
config.AppSettings.Settings["email"].Value = "r...@test.com";
config.Save(ConfigurationSaveMode.Minimal, true);
I get the message "Attempting to perform an unauthorized operation".
This is going to be a single user application with full write access
to the executable's path.
Thanks in advance.
Ryan

Why are you trying to do that?
Can't you use user settings instead which will be saved somewhere else?

--
Lasse Vågsæther Karlsen
mailto:la...@vkarlsen.nohttp://presentationmode.blogspot.com/- Hide quotedtext -

- Show quoted text -
Because I want all the configuration settings in one place, and the
settings aren't specific to a user.
Dec 7 '07 #4

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

Similar topics

6
by: msnews.microsoft.com | last post by:
Hi all, I was trying to find an easy way to write in the standard configuration (like app.config) xml-based files. I found classes that can be used to read this information (in...
4
by: UJ | last post by:
Is there a way to write into the .config file? In other words treat it like a .ini file. (I may be confused on what the exact nature of the .config file may be.) I can read from it fine but...
2
by: MK | last post by:
Is there any way to write into the app config at runtime? I want to store position, height and width of my forms.
8
by: Steve | last post by:
Can anyone tell me the preferred method for writing and retrieving persistent information using .Net. Specifically, I am referring to information that you used to see in registry keys or .ini...
16
by: Frank Oquendo | last post by:
ConfigurationSettings.AppSettings allows me to read from my config but how do I write to my config file? -- There are 10 kinds of people. Those who understand binary and those who don't. ...
19
by: Noozer | last post by:
I need to keep my application settings in a file that users can copy/backup/etc. Before I start using the old INI file standard, is there any easy way to use XML files to hold application...
1
by: ROO | last post by:
Hi Everyone, I need some help Creating Database Connection at runtime and writing Connection String to App.Config, I have 3mxtboxes on a form txtUsername = SQL admin User txtPassword = Sql admin...
9
by: WT | last post by:
Hello, I am writing a Web install project and I want to get the connection string from user and write it in the web.config of the installed web site. As the Websetup is a windows program, I use...
6
by: Peted | last post by:
Hi, im wanting to store some custom text strings in the app.config file of a c# app, to be retreived and updated when the app runs. using c# 2005 express in my testing i am using the code...
0
parshupooja
by: parshupooja | last post by:
Hey All, I have old vb.net application and I have various users for that.where I have XML file as datasource. Till now for each user application was installed seperately. only difference...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...

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.