C# file write permission issue under "Program Files" folder

Posted by George2 on Stack Overflow See other posts from Stack Overflow or by George2
Published on 2009-07-28T04:30:03Z Indexed on 2010/03/20 6:21 UTC
Read the original article Hit count: 425

Filed under:
|
|
|
|

Hello everyone,

I am using inno setup to make a installation package for my application, and my application is written by C# + .Net 2.0 + VSTS 2008. Inno setup => http://www.jrsoftware.org/isinfo.php and I install my application under Program Files/Foo folder (Foo is my application name). My application is targeting to Windows Vista.

The issue I found is my program cannot write to the folder Program Files/Foo. And I need the permission of write to this folder in order to save some configuration files. The strange thing I notice is the folder Program Files/Foo is marked as readonly and I have checked all folders under Program Files are marked with read only, such as Office.

My questions are,

  1. Why all folders are marked as read only under Program Files? It means we should not write to individual application folders under Program Files? If not, where should we write information to disk like user last selected configuration information of an individual application?
  2. If we could write to individual application folders under Program Files, what is the solution? I do not want my application to Run As administrator to solve this issue, and if there are solution to write to this folder, I want to require minimal permission if possible.

thanks in advance, George

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET