C# File System

Most of the time, you will need to be able to write your data to files for permanent storage. You will also need to be able to access the file system or the directory of the computer so that you can locate the files and load them, indicate the location where you want to save the file, view the files stored in that directory, or simply check the detail about that particular directory. You can even check how big the file is or if it is read-only. Although using a database is much preferred these days, using a text file is sufficient for simple and small programs. Also, some legacy programs still store their data in a text file so you need to incorporate writing and reading from a file.

The .NET Framework offers classes that you can use to read, write, and check the attributes of files and directories. You can use the instance versions, or the static versions of the class which offers the same capabilities with minimal differences. The following lessons will also teach you how to write a binary data and compressing files to make their size smaller.