
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
Streams In C#
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.
- Related Articles
- Streams and Byte Streams in C#
- Streams in Java
- Byte Streams in Java
- Character streams in Java
- What is the necessity of byte streams and character streams in Java?
- Streams on Arrays in Java 8
- An array of streams in C#
- What are Async Streams in C# 8.0?
- Difference between Streams and Collections in Java 8
- How to iterate List Using Streams in Java?
- Java 8 Streams and its operations
- Java streams counting() method with examples
- Iterate over lines from multiple input streams in Python
- What are cin, cout and cerr streams in C++?
- What are the methodologies of data streams clustering?
