Working with System.IO helper classes

The System.IO namespace contains a collection of classes that allow us to do file manipulation in C#. It includes classes that allow us to do operations such as the following:

  • Read data from a file
  • Write data to a file
  • Create/delete new files

At different points during this chapter, through code examples, we will look at all of these I/O operations that we can perform on a file. However, before we start looking at those examples, we need to understand a very important concept, Stream, on which I/O operations are based. 

A stream signifies a sequence of bytes exchanged between applications during an I/O operation. In C#, it's represented by an abstract class called System.IO.Stream. It provides a wrapper class to transfer bytes, and all classes that need to read/write bytes from any source must inherit from this particular class.

Before we move on to learn more about streams and how we deal with it them in C#, let's first look at how we deal with drives, directories, and some other basic operations with files.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.106.233