logo
CSharp_Prog_Guide

Надежное программирование

Этот пример иллюстрирует использование StringBuilder для изменения существующей строки. Обратите внимание, что это требует дополнительной декларации using, поскольку класс StringBuilder является членом пространства имен System.Text. Вместо того чтобы определять строку и затем преобразовывать ее в массив символов, с помощью примера можно напрямую создать и инициализировать массив символов.

В результате получаются следующие выходные данные.

Some number of characters to

How to: Add or Remove Access Control List Entries

To add or remove Access Control List (ACL) entries to or from a file, the FileSecurity or DirectorySecurity object must be obtained from the file or directory, modified, and then applied back to the file or directory.

To add or remove an ACL entry from a File

  1. Call the GetAccessControl method to get a FileSecurity object that contains the current ACL entries of a file.

  2. Add or remove ACL entries from the FileSecurity object returned from step 1.

  3. Pass the FileSecurity object to the SetAccessControl method to apply the changes.

To add or remove an ACL entry from a Directory

  1. Call the GetAccessControl method to get a DirectorySecurity object that contains the current ACL entries of a directory.

  2. Add or remove ACL entries from the DirectorySecurity object returned from step 1.

  3. Pass the DirectorySecurity object to the SetAccessControl method to apply the changes.