In an asp net app, I have a task that puts some XML files in a local folder on my computer. Then I want to read those files, but when they are copied to my local folder, their No network service user account is established. So, my question is, in Net C #, do you programmatically add "Network service" account to full control over your XML files.
In an asp net app, I have a task that puts some XML files in a local folder on my computer. Then I want to read those files, but when they are copied to my local folder, their No network service user account is established. So, my question is, in Net C #, do you programmatically add "Network service" account to full control over your XML files.
see
access control list (ACL) entry from the following code example file Adds and then uses file protection. You must provide a valid user or group account to run this example.
Using the system; Using System.IO; Using System.Security.AccessControl; Namespace file system display {class fileExample {public static zero main () {{string fileName = "test.xml"; Console "Written" ("Adding Access Control Entry to File Name"); // Add access control entry to the file. AddFileSecurity (filename, @ "DomainName \ AccountName", FileSystemRights.FullControl, AccessControlType.Allow); Remove Access Control Entry from the console (the "++ filename extracting entry control entry"); // RemoveFileSecurity (filename, @ "DomainName \ AccountName", FileSystemRights.FullControl, AccessControlType.Allow); Console.WriteLine ("Full.");} Hold (exception e) {Console.WriteLine (E);}} // Adds ACL entry to specified file for specified account. Public static zero AddFileSecurity (string filename, string account, filesystem rights rights , Accessor {Trolle type type control type} {// Get a file protection object that represents the current security settings. FileSecurity fSecurity = File.GetAccessControl (fileName); // Add FileSystemAccessRule to Security Settings FSecurity.AddAccessRule (New FileSystemAccessRule ( Account, rights, control type)) // Set new access settings File.SetAccessControl (filename, fSecurity);} Removes an ACL entry on the specified file for the specified account. Thatik zero RemoveFileSecurity (string filename, string account, Failsistmraits Rights, Akseskantrol type type control type) {// represents a file // current security settings that get security object. FileSecurity fSecurity = File.GetAccessControl (fileName); // Remove FileSystemAccessRule from Security Settings FSecurity.RemoveAccessRule (New FileSystemAccessRule (account, rights, type control)); // Set new access settings File.SetAccessControl (filename, fSecurity); }}}