access to the path "..." is denied.

I created a windows service project in visual studio 2005 using 2.0.  I have a Textboxes (A) add to the custom actions so the person doing the install can input an account key.  In my ProjectInstaller_BeforeInstall event handler I get the account key and write it to a file using:  
My.Computer.FileSystem.WriteAllText(My.Application.Info.DirectoryPath & "\cnxGZMON.config", sAccountKey, False)

After the service is started I can read the file OK and I get my account key OK using:  
My.Settings.AccountKey = Trim(My.Computer.FileSystem.ReadAllText(My.Application.Info.DirectoryPath & "\cnxGZMON.config"))

 The problem comes when I modify the account key and write it back to the file using:  
My.Computer.FileSystem.WriteAllText(My.Application.Info.DirectoryPath & "\cnxGZMON.config", sAccountKey, False)  (i.e., the save code as the original write above).  When I attempt this write I get an error:  
System.UnauthorizedAccessException--Access to the path 'C:\Program Files\Convina\cnxGZMONsetup\cnxGZMON.config' is denied.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Joel CoehoornDirector of Information TechnologyCommented:
The Program Files folder, and all sub folders, are read only to standard users.  This is by design.  Instead, use the application data folder:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cnxmaxAuthor Commented:
bingo.  danka.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.