Problem Context: While
dealing with windows application setups which will be normally installed in Program Files folder, will be facing
user rights issue (read only problem) on the database files inside application
This problem is due to the user folder permissions change in
Windows Vista and Windows 7. So the
application which was working fine earlier in Windows XP seems to create
problems in the above operating systems.
The problem will be visible even though the installer uses
administrative rights while installing the application.
Eg: If your application is installed in c:\Program
Files\Winapp and the log file inside it will be facing access rights issue
while updated using the application.
Following is the error message while trying to write to an
existing text file from the Program Files folder. The same file writing succeeded while
executed through Visual Studio.
There are many of solutions for the above problem. One of the solution is to use the special
folders for storing user updated files.
Eg: We can use the %ProgramData%
folder for storing the files.
points to c:\ProgramData (if windows drive is cJ
You can try executing it in the Run Window in Windows 7 OS.
On clicking Ok button
you can see the above folder opened in explorer.
Finding the Special
Folders in C#
We can get the folder path in runtime using the method given
We can store the user updated files in above folder like:
Access Database Files
The other special folders are shown in a separate article.
More Information can be found in: MSDN