Streams In C#

CsharpProgrammingServer Side Programming

The stream is basically the sequence of bytes passing through the communication path. There are two main streams: the input stream and the output stream. The input stream is used for reading data from file (read operation) and the output stream is used for writing into the file (write operation).

The FileStream class in the System.IO namespace helps in reading from, writing to and closing files. This class derives from the abstract class Stream.

Create a FileStream object to create a new file or open an existing file. The following is the syntax −

FileStream <object_name> = new FileStream( <file_name>, <FileMode Enumerator>,
<FileAccess Enumerator>, <FileShare Enumerator>);

Here,

FileMode

The FileMode enumerator defines various methods for opening files.

FileAccess

FileAccess enumerators have members: Read, ReadWrite and Write.

FileShare

FileShare enumerators have the following members − Inheritable, Read, ReadWrite, Write, etc.

raja
Updated on 20-Jun-2020 17:21:47

Advertisements