Home > Net >  For help, about the folder permissions to fail
For help, about the folder permissions to fail

Time:02-27

Directly in the project operation, is can change the folder permissions,
But package installed, found only performs to MessageBox. Show (" 44 ")
Behind a MessageBox. Show (" 66 ") will not pop up,
And he said, dir. SetAccessControl (dirSecurity) is not implemented,

For help, how to solve? Packaging have what matters needing attention, or program to modify?

The HTML code is as follows, c #, VB.net can ha
 
Public Sub New ()

InitializeComponent ()
AddSecurityControllFolder ()
End Sub


Private Shared Sub AddSecurityControllFolder ()
Dim dir As DirectoryInfo=New DirectoryInfo (Application. StartupPath)
Dim dirSecurity the As System. Security. The AccessControl. DirectorySecurity=dir. GetAccessControl ()


For Each rule As FileSystemAccessRule In dirSecurity. GetAccessRules (True, True, GetType (System. Security. Principal. NTAccount))
If rule.IdentityReference.Value.Com pareTo (" Everyone ")=0 Then
Return
End the If
Next
AddSecurityControll2Folder (Application. StartupPath)

End Sub

Private Shared Sub AddSecurityControll2Folder (ByVal dirPath As String)
Dim dir As DirectoryInfo=New DirectoryInfo (dirPath)
MessageBox. Show (" 11 ")
Dim dirSecurity the As System. Security. The AccessControl. DirectorySecurity=dir. GetAccessControl ()
MessageBox. Show (" 22 ")
Dim. [inherits] As InheritanceFlags=InheritanceFlags ContainerInherit Or InheritanceFlags. ObjectInherit
Dim everyoneFileSystemAccessRule As FileSystemAccessRule=New FileSystemAccessRule (" Everyone ", FileSystemRights FullControl, [inherits], PropagationFlags. None, AccessControlType. Allow)
Dim usersFileSystemAccessRule As FileSystemAccessRule=New FileSystemAccessRule (" Users ", FileSystemRights FullControl, [inherits], PropagationFlags. None, AccessControlType. Allow)
MessageBox. Show (" 33 ")
Dim isModified As Boolean=False
DirSecurity. ModifyAccessRule (AccessControlModification. Add, everyoneFileSystemAccessRule, isModified)
DirSecurity. ModifyAccessRule (AccessControlModification. Add, usersFileSystemAccessRule, isModified)
MessageBox. Show (" 44 ")
Dir. SetAccessControl (dirSecurity)
MessageBox. Show (" 66 ")
End Sub

CodePudding user response:

Project add: app. The manifest file, to look for in the file:
Instead of
CodePudding user response:

reference rabbit party at large on the second floor response:
add projects: app. The manifest file, to look for in the file:
Instead of


This set of words, not every start is the administrator to run?
So that the user experience is very poor
  •  Tags:  
  • C#
  • Related