O'Reilly logo

From Java to C#: A Developer's Guide by Heng Ngee Mok

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

18.3. Reading from or writing to a binary file

You can use the FileStream class for reading from or writing to a binary file.

18.3.1. Creating a FileStream object

You create an instance of a FileStream object by passing in the path to the file you want to read. The FileStream class has several overloaded constructors which you can use to specify the following options:

  • file mode

  • file access

  • file share.

Table 18.5 describes these options.

Table 18.5. The available file mode, access, and share options that can be used when instantiating a FileStream
EnumerationDescription
FileMode – how to open or create this file?
FileMode.AppendOpens a file, if it exists, for appending. Moves the file pointer to the end of the existing file, so that the original data ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required