Как открыть StreamReader в режиме ShareDenyWrite?

Как мне открытьStreamReader сFILE_SHARE_READ, FILE_SHARE_WRITE, FILE_SHARE_DELETE?

Same question, slightly expanded

Как мне открытьStreamReader чтобы я мог прочитать закодированный текстовый файл с опциями общего доступа, чтобы другой процесс мог прочитать файл?

Как мне открытьStreamReader чтобы я мог прочитать закодированный текстовый файл с опциями общего доступа, чтобы другой процесс мог изменить файл, пока я его читаю?

Как мне открытьStreamReader чтобы я мог прочитать закодированный текстовый файл с опциями общего доступа, чтобы другой процесс мог удалить файл, пока я его читаю?

Same question, slightly more expanded

В библиотеке классов .NET Framework есть класс, называемыйStreamReader, Это единственный класс, предназначенный для чтения"text"вот почему он спускается с абстрактной базыTextReader учебный класс.TextReader/StreamReader позволяет указать кодировку, используемую файлом, который вы пытаетесь открыть, и может декодировать файл для вас, возвращаяStrings текста.

Как только я открыл файл сStreamReader:

var sr = new StreamReader(path);

Файл заблокирован, другие процессы не могутmodify или жеdelete файл. Что мне нужно, это эквивалентFileStream Класс & APOS; sFileShare перечисление:

None: Declines sharing of the current file. Any request to open the file (by this process or another process) will fail until the file is closed. Read": Allows subsequent opening of the file for reading. If this flag is not specified, any request to open the file for reading (by this process or another process) will fail until the file is closed. However, even if this flag is specified, additional permissions might still be needed to access the file. Write: Allows subsequent opening of the file for writing. If this flag is not specified, any request to open the file for writing (by this process or another process) will fail until the file is closed. However, even if this flag is specified, additional permissions might still be needed to access the file. ReadWrite:Allows subsequent opening of the file for reading or writing. If this flag is not specified, any request to open the file for reading or writing (by this process or another process) will fail until the file is closed. However, even if this flag is specified, additional permissions might still be needed to access the file. Delete: Allows subsequent deleting of a file.

За исключением того, что по понятным причинам я не могу использоватьFileStream - должны использоватьStreamReader.

Как я могу открытьStreamReader сFileShare.ReadWrite | FileShare.Delete?

Ответы на вопрос(2)

Ваш ответ на вопрос