|
Hello, When I made the installer, and installed the app I am working on (in program files/program), and tried to run it, it crashed (due to fail in read/write permissions in some text files that are in the same folder as the application). I am wondering, how could I solve this problem easily (I use .NET 2.0 at this moment). Is there any way the app can auto-detect if admin permissions are required and ask for them? - Moved byOmegaManMVPTuesday, May 19, 2009 5:08 PM (From:Visual C# General)
-
| | GVNPublic123 Tuesday, May 19, 2009 5:01 PM | You have to have administrator privileges to update or create files in the Program Files folder. The Program Files folder is just the wrong place for data files that are updated by the app.User-specific folders should be used, such as Environment.SpecialFolders.ApplicationData. Phil Wilson- Marked As Answer byKira QianMSFT, ModeratorTuesday, May 26, 2009 6:31 AM
-
| | PhilWilson Tuesday, May 19, 2009 5:36 PM | Hi GVNPublic123,
You can give that file "FullControl" for "Everyone" using FileSystemAccessRule Class, Here is the example of this class. http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.filesystemaccessrule.aspx
The FileSystemAccessRule class represents an abstraction of an underlying access control entry (ACE) that specifies a user account, the type of access to provide (read, write, and so on), and whether to allow or deny that right. This class can also specify how access rules are propagated to child objects.
When you do this in your code, it is equal to right click that file turn to properties and grant the permission in the "Security" tabpage. If "Everyone" has full control, then each account on your computer should have right to modify that file.
You can do this at the end of your installation using custom action.
Holp this helps.
Sincerely, Kira Qian
Please mark the replies as answers if they help and unmark if they don't. - Marked As Answer byKira QianMSFT, ModeratorTuesday, May 26, 2009 6:31 AM
-
| | Kira Qian Thursday, May 21, 2009 2:43 AM | Or can I anyhow edit the register while installing, so it always provides admin permissions for the app? | | GVNPublic123 Tuesday, May 19, 2009 5:02 PM | I forgot to mention, I have custom installer, not the VS one. | | GVNPublic123 Tuesday, May 19, 2009 5:20 PM | You have to have administrator privileges to update or create files in the Program Files folder. The Program Files folder is just the wrong place for data files that are updated by the app.User-specific folders should be used, such as Environment.SpecialFolders.ApplicationData. Phil Wilson- Marked As Answer byKira QianMSFT, ModeratorTuesday, May 26, 2009 6:31 AM
-
| | PhilWilson Tuesday, May 19, 2009 5:36 PM | Any suggestions how should I make this thing right? | | GVNPublic123 Tuesday, May 19, 2009 6:39 PM | Hi GVNPublic123,
You can give that file "FullControl" for "Everyone" using FileSystemAccessRule Class, Here is the example of this class. http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.filesystemaccessrule.aspx
The FileSystemAccessRule class represents an abstraction of an underlying access control entry (ACE) that specifies a user account, the type of access to provide (read, write, and so on), and whether to allow or deny that right. This class can also specify how access rules are propagated to child objects.
When you do this in your code, it is equal to right click that file turn to properties and grant the permission in the "Security" tabpage. If "Everyone" has full control, then each account on your computer should have right to modify that file.
You can do this at the end of your installation using custom action.
Holp this helps.
Sincerely, Kira Qian
Please mark the replies as answers if they help and unmark if they don't. - Marked As Answer byKira QianMSFT, ModeratorTuesday, May 26, 2009 6:31 AM
-
| | Kira Qian Thursday, May 21, 2009 2:43 AM |
|