- FileStream - reads & writes files
- IsolatedStorageFileStream - Reads & wrties files in Isolated Storage
- MemoryStream - Reads & writes data to memory
- BufferedStream - Used to store bytes in memory to cache data
- NetworkStream - reads & writes Data over a network socket
- PipeStream - reads & writes data over an anonymous or named pipes
- CryptoStream - Used to link data streams to cryptographic transformations
Streams are used for reading or writing to byte arrays. For example
using System;
using System.IO;
using System.Text;
namespace pc.SimpleStreams
{
class Program
{
static void Main(string[] args)
{
//Create byte
array holding bytes for string
byte[] helloWorld = Encoding.ASCII.GetBytes("hello world");
//Create byte
array of eqaul size
byte[] HELLOWORLD = new byte[helloWorld.Length];
//user two
memory streams one to itterate over bytes
//the second to
write those bytes transformed into
//uppercase
using (var ms = new MemoryStream(helloWorld))
using (var MS = new MemoryStream(HELLOWORLD))
{
int value = ms.ReadByte();
while (value != -1)
{
MS.WriteByte((byte)(value - 32));
value = ms.ReadByte();
}
}
//output
contenets of byte array as string
Console.WriteLine(Encoding.ASCII.GetString(HELLOWORLD));
}
}
}