Lecture overview -- Keyboard shortcut: 'u'  Previous page: Subclasses of class Stream -- Keyboard shortcut: 'p'  Next page: The using control structure -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 6 : 40
Object-oriented Programming in C#
Input and Output Classes
Example: Filestreams

Class FileStream is a non-abstract subclass of class Stream

We show the simplest possible write and read programs using class FileStream

 

/user/normark/oop-csharp-1/sources/c-sharp/io/filestream-ex/1/write-prog.csA program that writes bytes corresponding to 'O' 'O' 'P' to a file stream.


/user/normark/oop-csharp-1/sources/c-sharp/io/filestream-ex/1/myFile.binThe contents of myFile.bin - interpreted as simple ASCII text - after executing the write program.


/user/normark/oop-csharp-1/sources/c-sharp/io/filestream-ex/1/read-prog.csA program that reads the written file.


/user/normark/oop-csharp-1/sources/c-sharp/io/filestream-ex/1/outputConsole output from the read program.


Class FileStream offers binary input and output