Programmatically adding security permissions to files in C#
问题 In an asp.net app, I have a task that ftps some xml files down to a local folder on my computer. I then want to read those files but when they're copied to my local folder, they don't have the Network Service user account set up. So, my question is how, in .Net C#, do you programmatically add the "Network Service" account with full control to my xml files. 回答1: See the FileSecurity class in MSDN The following code example uses the FileSecurity class to add and then remove an access control