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>);



The FileMode enumerator defines various methods for opening files.


FileAccess enumerators have members: Read, ReadWrite and Write.


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

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