.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

Home >> Articles >> C# >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Program Files - Access Rights Problem in Windows 7

Posted By:Jean Paul       Posted Date: October 19, 2011    Points: 200    Category: C#    URL: http://www.dotnetspark.com  

access rights problem winforms setup

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 folder.


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. 

The %ProgramData% 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 below.





We can store the user updated files in above folder like:


  • MS Access Database Files
  • Log Files
  • Settings file


The other special folders are shown in a separate article.


More Information can be found in: MSDN Blog

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend