Example

 using System; using System.IO; using System.Text; namespace Samples { public class FileStreamSample { public static void Main() { string s = "filestream.txt"; using(FileStream fs = new FileStream(s, FileMode.OpenOrCreate, FileAccess.Write)) { Console.WriteLine("FileStream opened on {0} ", fs.Name); DisplayInformationAboutStream(fs); string ds = String.Format("Written at: {0}\n", DateTime.Now.ToString()); UTF8Encoding e = new UTF8Encoding(); int count = e.GetByteCount(ds.ToCharArray(), 0, ds.Length); Byte[] bytes = new Byte[count]; e.GetBytes(ds, 0, ds.Length, bytes, 0); fs.Seek(0, SeekOrigin.End); fs.Write(bytes, 0, bytes.Length); } using(FileStream fs = new FileStream(s, FileMode.Open, FileAccess.Read)) { Console.WriteLine("FileStream ...

Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.