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.
For a more comprehensive listing, see 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 |
---|---|
System.IO.Directory | Provides static methods for creating, moving, and enumerating through directories and subdirectories. |
System.IO.DirectoryInfo | Provides instance methods for creating, moving, and enumerating through directories and subdirectories. |
System.IO.DriveInfo | Provides instance methods for creating, moving, and enumerating through drives. |
System.IO.File | Provides static methods for creating, copying, deleting, moving, and opening files, and aids in the creation of a FileStream . |
System.IO.FileAccess | Defines constants for read, write, or read/write access to a file. |
System.IO.FileAttributes | Provides attributes for files and directories such as Archive , Hidden , and ReadOnly . |
System.IO.FileInfo | Provides static methods for creating, copying, deleting, moving, and opening files, and aids in the creation of a FileStream . |
System.IO.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. |
System.IO.FileShare | Defines constants for controlling the type of access other file streams can have to the same file. |
System.IO.Path | Provides methods and properties for processing directory strings. |
System.Security.Permissions.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 |
---|---|
System.IO.BufferedStream | Adds a buffering layer to read and write operations on another stream. |
System.IO.FileStream | Supports random access to files through its Seek method. FileStream opens files synchronously by default but also supports asynchronous operation. |
System.IO.MemoryStream | Creates a stream whose backing store is memory, rather than a file. |
System.Net.Sockets.NetworkStream | Provides the underlying stream of data for network access. |
System.Security.Cryptography.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 |
---|---|
System.IO.BinaryReader | Reads encoded strings and primitive data types from a FileStream. |
System.IO.BinaryWriter | Writes encoded strings and primitive data types to a FileStream. |
System.IO.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. |
System.IO.StreamWriter | Writes characters to a FileStream , using Encoding to convert characters to bytes. |
System.IO.StringReader | Reads characters from a String . Output can be either a stream in any encoding or a String . |
System.IO.StringWriter | Writes characters to a String . Output can be either a stream in any encoding or a String . |
See also
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.