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

 

Updated: July 20, 2015

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

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 Class Library Overview.

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

ClassDescription
System.IO.DirectoryProvides static methods for creating, moving, and enumerating through directories and subdirectories.
System.IO.DirectoryInfoProvides instance methods for creating, moving, and enumerating through directories and subdirectories.
System.IO.DriveInfoProvides instance methods for creating, moving, and enumerating through drives.
System.IO.FileProvides static methods for creating, copying, deleting, moving, and opening files, and aids in the creation of a FileStream.
System.IO.FileAccessDefines constants for read, write, or read/write access to a file.
System.IO.FileAttributesProvides attributes for files and directories such as Archive, Hidden, and ReadOnly.
System.IO.FileInfoProvides static methods for creating, copying, deleting, moving, and opening files, and aids in the creation of a FileStream.
System.IO.FileModeControls 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.
System.IO.FileShareDefines constants for controlling the type of access other file streams can have to the same file.
System.IO.PathProvides methods and properties for processing directory strings.
System.Security.Permissions.FileIOPermissionControls the access of files and folders by defining Read, Write, Append and PathDiscovery permissions.

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

ClassDescription
System.IO.BufferedStreamAdds a buffering layer to read and write operations on another stream.
System.IO.FileStreamSupports random access to files through its Seek method. FileStream opens files synchronously by default but also supports asynchronous operation.
System.IO.MemoryStreamCreates a stream whose backing store is memory, rather than a file.
System.Net.Sockets.NetworkStreamProvides the underlying stream of data for network access.
System.Security.Cryptography.CryptoStreamDefines a stream that links data streams to cryptographic transformations.

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

ClassDescription
System.IO.BinaryReaderReads encoded strings and primitive data types from a FileStream.
System.IO.BinaryWriterWrites encoded strings and primitive data types to a FileStream.
System.IO.StreamReaderReads 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.
System.IO.StreamWriterWrites characters to a FileStream, using Encoding to convert characters to bytes.
System.IO.StringReaderReads characters from a String. Output can be either a stream in any encoding or a String.
System.IO.StringWriterWrites characters to a String. Output can be either a stream in any encoding or a String.

Composing Streams
File and Stream I-O
Asynchronous File I/O
Basics of .NET Framework File I/O and the File System (Visual Basic)

Show: