Basic Stream operations
// Convert the stream into a file
Public static void StreamToFile (Stream stream, string filepath) {byte [] bytes = StreamToBytes (stream); FileStream fileStream = new FileStream (filepath, FileMode. create); fileStream. write (bytes, 0, bytes. length); fileStream. flush (); fileStream. close ();}
// Convert the stream into a byte arrayPublic static byte [] StreamToBytes (Stream stream) {MemoryStream memoryStream = new MemoryStream (); stream. CopyTo (memoryStream); return memoryStream. ToArray ();}
// Convert the stream to a Base64 string
Public static string StreamToString (Stream stream) {byte [] buffer = new byte [Stream. length]; stream. read (buffer, 0, (int) stream. length); string base64string = Convert. toBase64String (buffer); return base64string ;}
// Convert a Base64 string to a stream
Pubblic static Stream StringToStream (string str)
{
Byte [] bt = Convert. FromBase64String (str );
System. IO. MemoryStream stream = new System. IO. MemoryStream (bt );
}
..............