Link to home
Start Free TrialLog in
Avatar of ddepuemd
ddepuemd

asked on

Vista and XP permissions problem

How do you make sure the installation directory allows writing by the user?  How can you make sure to change the settings in a Deployment project?
ASKER CERTIFIED SOLUTION
Avatar of CraigLazar
CraigLazar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ddepuemd
ddepuemd

ASKER

I have tried this:

 Dim CurrentPath as String = "C:\TestPath"
 Dim UserName as String = system.environment.username
 
 Dim dInfo As New DirectoryInfo(CurrentPath)
 Dim dSecInfo As DirectorySecurity = dInfo.GetAccessControl(AccessControlSections.Access)
 Dim myRuleValue As Integer = 0
 
 myRuleValue =  FileSystemRights.FullControl   'Add your wanted Access here
 Dim myRule as FileSystemAccessRule
 myRule = New FileSystemAccessRule(UserName myRuleValue, InheritanceFlags.ContainerInherit Or InheritanceFlags.ObjectInherit Or InheritanceFlags.None, PropagationFlags.None, AccessControlType.Allow)
 dSecInfo.AddAccessRule(myRule)
 dSecInfo.SetAccessRule(myRule)
 dInfo.SetAccessControl(dSecInfo)

but it fails because it is not giving permission for the function to set the rule.  Any ideas on how to set the rule as administrator???
currentpath should have been curdir()
I've modified the code to write that database to the users directory instead of program files...
good stuff well done, :)