file write permission issue under “Program Files” folder

前端 未结 3 404
情深已故
情深已故 2020-11-28 10:38

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/

相关标签:
3条回答
  • 2020-11-28 11:17

    A common solution would be to install configuration files to the Application Data folder i.e. like follows:

    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
    
    0 讨论(0)
  • 2020-11-28 11:24

    You should write user specific config data to the Application Data folder for the current user, using the special folders enum and the Enivronment.GetFolderPath.

    0 讨论(0)
  • 2020-11-28 11:24

    Best Practice is to not store config data in the Program Files folder. Instead, store your application's data in %AppData%\YourApplicationName. Depending on whether you want to store your config data per-user or in a shared common folder, use one of the following enums to get the folder path:

    string userAppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);  
    string commonAppData = Envrionment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); 
    

    By default, Vista users do not run programs as Administrators and hence those programs have only read access to the folders under "Program Files". Users can change this behavior by disabling UAC and you could ask your users to do that, but in an office setting users might not have that option. That's why you use AppData instead -- applications can always read and write data to the AppData folder.

    Information on UAC can be found at Microsoft's site. Although this page is fairly long, it's a starting point for understanding UAC: http://msdn.microsoft.com/en-us/library/bb530410.aspx

    0 讨论(0)
提交回复
热议问题