File and Directory operations in C#.Net

File handling in C#.Net is similar to the Java.

All file related classes are stored in the System.IO namespace.

Some of the important classes are –

  1. FileStream – Allows reading and writing to the files
  2. StreamReader – Allows reading from any stream
  3. StreamWriter – Allows writing to any stream

Other important file system tasks that could be done are-

  1. Checking the size of file
  2. Checking if directory exists
  3. Deleting the file and directory
  4. Appending the contents to file
  5. Creating new files

You may also like...