C # modify the permissions of files or folders to add full control permissions to specified users and user groups
// Add the "Everyone, Users" User Group's full control permission FileInfo fi = new FileInfo (excelPath); System to the Excel file. security. accessControl. fileSecurity fileSecurity = fi. getAccessControl (); fileSecurity. addAccessRule (new FileSystemAccessRule ("Everyone", FileSystemRights. fullControl, AccessControlType. allow); fileSecurity. addAccessRule (new FileSystemAccessRule ("Users", FileSystemRights. fullControl, AccessControlType. allow); fi. setAccessControl (fileSecurity); // Add the "Everyone, Users" User Group's full control permission DirectoryInfo di = new DirectoryInfo (Path. getDirectoryName (excelPath); System. security. accessControl. directorySecurity dirSecurity = di. getAccessControl (); dirSecurity. addAccessRule (new FileSystemAccessRule ("Everyone", FileSystemRights. fullControl, AccessControlType. allow); dirSecurity. addAccessRule (new FileSystemAccessRule ("Users", FileSystemRights. fullControl, AccessControlType. allow); di. setAccessControl (dirSecurity );