System.IO Namespace in C#


System.IO namespace contains types that provide basic File and Directory manipulation functions. This namespace also includes lot of types that support reading and writing to files and data streams. Mscorlib.dll and System.dll assemblies contain the types in System.IO namespace.

Below table lists some of the useful types available in System.IO Namespace.

Type Name

Description

BinaryReader

Provides functionality to read primitive data types as a binary value in specific encoding

BinaryWriter

Provides functionality to write primitive data types in specific encoding.

Directory

Provides static functions to manipulate machines directory structure

DirectoryInfo

Provides functions to manipulate machines directory structure. Similar to Directory class but provides instance level methods.

DriveInfo

Provides functionality to manage system drives information.

File

Provides static functions to manage files in the system.

FileInfo

Provides functionality to manipulate the files. Similar to File class but provides functions at instance level.

FileStream

This class provides access to the file data as stream of bytes. Also provides seeking facility, you can move to specific location of the file by index.

FileSystemWatcher

Monitors the file system for events like creation, modified, deletion, etc.

MemoryStream

This class provides functions to work on stream of bytes in memory.

Path

Provides functions to get directory and file paths.

StreamReader

Provides functions to read file data as strings.

StreamWriter

Provides functions to write text data to file.

StringReader

Provides functions to read data from a text buffer

StringWriter

Provides functions to write data to text buffer.

 

 Below table lists some of the useful enumerations available in System.IO namespace.

Enumeration

Description

DriveType

Defines constants for different Drive types.

FileAccess

Defines constants read, write, and read/write access to a file.

FileMode

Defines constants for file open mode.

FileOptions

Additional options for creating a FileStream object

SearchOption

Provides constants to search high level directory or include sub directories.

SeekOrigin

Provides constants to start from a certain position in the Stream