Classes Used in .NET Framework File I/O and the File System (Visual Basic)

The following tables list the classes commonly used for .NET Framework file I/O, categorized into file I/O classes, classes used for creating streams, and classes used to read and write to streams.

To enter the .NET Framework 2.0 documentation and find a more comprehensive listing, see .NET Framework Class Library Overview.

Basic I/O Classes for Files, Drives, and Directories

The following table lists and describes the main classes used for file I/O.

Class

Description

Directory

Provides static methods for creating, moving, and enumerating through directories and subdirectories.

DirectoryInfo

Provides instance methods for creating, moving, and enumerating through directories and subdirectories.

DriveInfo

Provides instance methods for creating, moving, and enumerating through drives.

File

Provides static methods for creating, copying, deleting, moving, and opening files, and aids in the creation of a FileStream.

FileAccess

Defines constants for read, write, or read/write access to a file.

FileAttributes

Provides attributes for files and directories such as Archive, Hidden, and ReadOnly.

FileInfo

Provides static methods for creating, copying, deleting, moving, and opening files, and aids in the creation of a FileStream.

FileMode

Controls how a file is opened. This parameter is specified in many of the constructors for FileStream and IsolatedStorageFileStream, and for the Open methods of File and FileInfo.

FileShare

Defines constants for controlling the type of access other file streams can have to the same file.

Path

Provides methods and properties for processing directory strings.

FileIOPermission

Controls the access of files and folders by defining Read, Write, Append and PathDiscovery permissions.

Classes Used to Create Streams

The following table lists and describes the main classes used to create streams.

Class

Description

BufferedStream

Adds a buffering layer to read and write operations on another stream.

FileStream

Supports random access to files through its Seek method. FileStream opens files synchronously by default but also supports asynchronous operation.

MemoryStream

Creates a stream whose backing store is memory, rather than a file.

NetworkStream

Provides the underlying stream of data for network access.

CryptoStream

Defines a stream that links data streams to cryptographic transformations.

Classes Used to Read from and Write to Streams

The following table shows the specific classes used for reading from and writing to files with streams.

Class

Description

BinaryReader

Reads encoded strings and primitive data types from a FileStream.

BinaryWriter

Writes encoded strings and primitive data types to a FileStream.

StreamReader

Reads characters from a FileStream, using CurrentEncoding to convert characters to and from bytes. StreamReader has a constructor that attempts to ascertain the correct CurrentEncoding for a given stream, based on the presence of a CurrentEncoding-specific preamble, such as a byte order mark.

StreamWriter

Writes characters to a FileStream, using Encoding to convert characters to bytes.

StringReader

Reads characters from a String. Output can be either a stream in any encoding or a String.

StringWriter

Writes characters to a String. Output can be either a stream in any encoding or a String.

See Also

Concepts

Composing Streams

Asynchronous File I/O

Basics of .NET Framework File I/O and the File System (Visual Basic)

Other Resources

File and Stream I/O