General BS Program This requires that the network service user has the write permission on the folder. In general, we use the script of the package to call the package to set permissions, manual setting is more important when you do not package. It is not complicated to set and deploy only one or two folders. However, when the system can install modules, the number of modules may be large, but it is difficult to put all the files in a directory. In this case, it is advantageous to allow the program to set specific permissions dynamically.
It took half a day to check the information. The first thought was to see if the system had such a command. Right away, CMD typed help and press Enter. A cacls seemed to have seen hope, after a brief look at the help information, search for other people's experience, and finally find that this is only a modification to the file operation permissions, and cannot set permissions on folders. Finally in the http://www.codeproject.com/dotnet/NTSecurityNET.asp found a class library written with VC ++, very convenient to use, also relatively simple, effective after testing. Close up to share with you. Here is an example I wrote: String Accountname = System. environment. Username;
String System = System. environment. machinename;
Accountname = " NETWORK SERVICE " ;
Microsoft. win32.security. windowsuser Wu = New Microsoft. win32.security. windowsuser (accountname, system );
Securedobject so = New Securedobject ();
So. objectname = @" D: \ test " ;
So. objecttype = Securedobjecttype. fileobject;
So. permissions. setaccess (Wu, accessrights. filewriteunsync, aceinheritanceflags. containerinherit | Aceinheritanceflags. objectinherit );