C# File Handling Tutorial with Complete Programming Example

In this chapter you will learn
  • What is File Handling in C#?
  • Why I need to learn File Handling?
  • What is Files and Stream?

What is File Handling in C#?

To save the information permanently on the disk or reading information from the saved file through C# is known as File Handling. C# File Handling uses a stream to save or retrieve information.

Files and Stream

A file is a collection of data stored on a disk with specific name, extension and directory path. When you open File using C# for reading and writing purpose it becomes Stream. A stream is a sequence of bytes traveling from a source to a destination over a communication path.

Why I need to learn File Handling?

As a C# programmer, several times you need to save information on a disk. You will not get database everywhere to save information and your project may require saving information in a txt file, doc file, xls file, pdf files or any other file types. So, you must know the concept of saving data in a file.


What I will learn in this section?

You will learn about System.IO Namespace which is a collection of classes that is responsible for reading, writing and accessing of files. Then, in the next few chapters you will learn how to read and write files, stream and string, directory info and file info.


This chapter is just an overview of File Handling Tutorial and in the next few chapters you will learn about all the classes of I/O and also learn how to use this class in programming for reading and writing file on a disk. In the next chapter you will learn System.IO NameSpace.


Share your thought