This article introduces and describes streams and their properties, version information, methods, syntax and so on with examples. In this article I also describe the file class and directory class.
Stream | Introduction
We can perform two operations on a file:
- Move data into it.
- Move data out of it
These operations can be performed across the network, over the internet or anywhere else depending on you. But the data you do process must be streamed.
Stream Class
Stream Data
Stream data can be stored or forwarded over the network via these three backing stores or we can call it backup of the streamed data.
These backing stores are:
Properties | Streams
- A stream can be:
1. Readable
2. Writeable
3. Both
- Streams can also be seekable or we can say that some types of streams can support a current position that can be queried or modified.
- All streams derive from an abstract base class:
System.IO.Stream
Stream | Hierarchy
Syntax
Here is some syntax for the Stream class:
Methods
There are several methods used in the Stream class, some of them am presented here. For more details you can go to
msdn.channel9.
Version Information
Inheritance Hierarchy
You can also go through these:
Example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Hello_Word
{
class Struct
{
public struct Point
{
private int xCord;
private int yCord;
public Point(int x, int y)
{
xCord = x;
yCord = y;
}
public int x
{
get { return xCord; }
set { xCord = value; }
}
public int y
{
get { return xCord; }
set { xCord = value; }
}
}
}
File Classes
The System.IO namespace provides functionality for file classes.
Working with Classes
There are generally 3 types of file classes provided by the System.IO namespace in C# and they are as follows:
Directory Classes
- The System.IO namespace also provides directory classes along with file classes.
- There are the following 2 types of these classes:
1. Directory
2. DirectoryInfo