mscorlib(4.0.0.0) API with additions
System.IO Namespace Reference

Classes

class  BinaryReader
 Reads primitive data types as binary values in a specific encoding. More...
 
class  BinaryWriter
 Writes primitive types in binary to a stream and supports writing strings in a specific encoding. More...
 
class  BufferedStream
 Adds a buffering layer to read and write operations on another stream. This class cannot be inherited. More...
 
class  Directory
 Exposes static methods for creating, moving, and enumerating through directories and subdirectories. This class cannot be inherited.To browse the .NET Framework source code for this type, see the Reference Source. More...
 
class  DirectoryInfo
 Exposes instance methods for creating, moving, and enumerating through directories and subdirectories. This class cannot be inherited.To browse the .NET Framework source code for this type, see the Reference Source. More...
 
class  DirectoryNotFoundException
 The exception that is thrown when part of a file or directory cannot be found. More...
 
class  DriveInfo
 Provides access to information on a drive. More...
 
class  DriveNotFoundException
 The exception that is thrown when trying to access a drive or share that is not available. More...
 
class  EndOfStreamException
 The exception that is thrown when reading is attempted past the end of a stream. More...
 
class  ErrorEventArgs
 Provides data for the E:System.IO.FileSystemWatcher.Error event. More...
 
class  File
 Provides static methods for the creation, copying, deletion, moving, and opening of a single file, and aids in the creation of T:System.IO.FileStream objects.To browse the .NET Framework source code for this type, see the Reference Source. More...
 
class  FileInfo
 Provides properties and instance methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of T:System.IO.FileStream objects. This class cannot be inherited.To browse the .NET Framework source code for this type, see the Reference Source. More...
 
class  FileLoadException
 The exception that is thrown when a managed assembly is found but cannot be loaded. More...
 
class  FileNotFoundException
 The exception that is thrown when an attempt to access a file that does not exist on disk fails. More...
 
class  FileStream
 Provides a T:System.IO.Stream for a file, supporting both synchronous and asynchronous read and write operations.To browse the .NET Framework source code for this type, see the Reference Source. More...
 
class  FileSystemEventArgs
 Provides data for the directory events: E:System.IO.FileSystemWatcher.Changed, E:System.IO.FileSystemWatcher.Created, E:System.IO.FileSystemWatcher.Deleted. More...
 
class  FileSystemInfo
 Provides the base class for both T:System.IO.FileInfo and T:System.IO.DirectoryInfo objects. More...
 
class  FileSystemWatcher
 Listens to the file system change notifications and raises events when a directory, or file in a directory, changes.To browse the .NET Framework source code for this type, see the Reference Source. More...
 
class  InternalBufferOverflowException
 The exception thrown when the internal buffer overflows. More...
 
class  InvalidDataException
 The exception that is thrown when a data stream is in an invalid format. More...
 
class  IODescriptionAttribute
 Sets the description visual designers can display when referencing an event, extender, or property. More...
 
class  IOException
 The exception that is thrown when an I/O error occurs. More...
 
class  MemoryStream
 Creates a stream whose backing store is memory.To browse the .NET Framework source code for this type, see the Reference Source. More...
 
class  Path
 Performs operations on T:System.String instances that contain file or directory path information. These operations are performed in a cross-platform manner.To browse the .NET Framework source code for this type, see the Reference Source. More...
 
class  PathTooLongException
 The exception that is thrown when a path or fully qualified file name is longer than the system-defined maximum length. More...
 
class  RenamedEventArgs
 Provides data for the E:System.IO.FileSystemWatcher.Renamed event. More...
 
class  Stream
 Provides a generic view of a sequence of bytes. This is an abstract class.To browse the .NET Framework source code for this type, see the Reference Source. More...
 
class  StreamReader
 Implements a T:System.IO.TextReader that reads characters from a byte stream in a particular encoding.To browse the .NET Framework source code for this type, see the Reference Source. More...
 
class  StreamWriter
 Implements a T:System.IO.TextWriter for writing characters to a stream in a particular encoding.To browse the .NET Framework source code for this type, see the Reference Source. More...
 
class  StringReader
 Implements a T:System.IO.TextReader that reads from a string. More...
 
class  StringWriter
 Implements a T:System.IO.TextWriter for writing information to a string. The information is stored in an underlying T:System.Text.StringBuilder. More...
 
class  TextReader
 Represents a reader that can read a sequential series of characters. More...
 
class  TextWriter
 Represents a writer that can write a sequential series of characters. This class is abstract. More...
 
class  UnmanagedMemoryAccessor
 Provides random access to unmanaged blocks of memory from managed code. More...
 
class  UnmanagedMemoryStream
 Provides access to unmanaged blocks of memory from managed code. More...
 
struct  WaitForChangedResult
 Contains information on the change that occurred. More...
 

Enumerations

enum  DriveType {
  DriveType.Unknown, DriveType.NoRootDirectory, DriveType.Removable, DriveType.Fixed,
  DriveType.Network, DriveType.CDRom, DriveType.Ram
}
 Defines constants for drive types, including CDRom, Fixed, Network, NoRootDirectory, Ram, Removable, and Unknown. More...
 
enum  FileAccess { FileAccess.Read = 0x1, FileAccess.Write = 0x2, FileAccess.ReadWrite = 0x3 }
 Defines constants for read, write, or read/write access to a file. More...
 
enum  FileAttributes {
  FileAttributes.ReadOnly = 0x1, FileAttributes.Hidden = 0x2, FileAttributes.System = 0x4, FileAttributes.Directory = 0x10,
  FileAttributes.Archive = 0x20, FileAttributes.Device = 0x40, FileAttributes.Normal = 0x80, FileAttributes.Temporary = 0x100,
  FileAttributes.SparseFile = 0x200, FileAttributes.ReparsePoint = 0x400, FileAttributes.Compressed = 0x800, FileAttributes.Offline = 0x1000,
  FileAttributes.NotContentIndexed = 0x2000, FileAttributes.Encrypted = 0x4000, FileAttributes.IntegrityStream = 0x8000, FileAttributes.NoScrubData = 0x20000
}
 Provides attributes for files and directories. More...
 
enum  FileMode {
  FileMode.CreateNew = 1, FileMode.Create, FileMode.Open, FileMode.OpenOrCreate,
  FileMode.Truncate, FileMode.Append
}
 Specifies how the operating system should open a file. More...
 
enum  FileOptions {
  FileOptions.None = 0x0, FileOptions.WriteThrough = int.MinValue, FileOptions.Asynchronous = 0x40000000, FileOptions.RandomAccess = 0x10000000,
  FileOptions.DeleteOnClose = 0x4000000, FileOptions.SequentialScan = 0x8000000, FileOptions.Encrypted = 0x4000
}
 Represents advanced options for creating a T:System.IO.FileStream object. More...
 
enum  FileSecurityStateAccess {
  NoAccess = 0x0, Read = 0x1, Write = 0x2, Append = 0x4,
  PathDiscovery = 0x8, AllAccess = 0xF
}
 
enum  FileShare {
  FileShare.None = 0x0, FileShare.Read = 0x1, FileShare.Write = 0x2, FileShare.ReadWrite = 0x3,
  FileShare.Delete = 0x4, FileShare.Inheritable = 0x10
}
 Contains constants for controlling the kind of access other T:System.IO.FileStream objects can have to the same file. More...
 
enum  HandleInheritability { HandleInheritability.None, HandleInheritability.Inheritable }
 Specifies whether the underlying handle is inheritable by child processes. More...
 
enum  LogRetentionOption {
  SingleFileUnboundedSize = 2, SingleFileBoundedSize = 4, UnlimitedSequentialFiles = 0, LimitedSequentialFiles = 3,
  LimitedCircularFiles = 1
}
 
enum  NotifyFilters {
  NotifyFilters.FileName = 0x1, NotifyFilters.DirectoryName = 0x2, NotifyFilters.Attributes = 0x4, NotifyFilters.Size = 0x8,
  NotifyFilters.LastWrite = 0x10, NotifyFilters.LastAccess = 0x20, NotifyFilters.CreationTime = 0x40, NotifyFilters.Security = 0x100
}
 Specifies changes to watch for in a file or folder. More...
 
enum  SearchOption { SearchOption.TopDirectoryOnly, SearchOption.AllDirectories }
 Specifies whether to search the current directory, or the current directory and all subdirectories. More...
 
enum  SeekOrigin { SeekOrigin.Begin, SeekOrigin.Current, SeekOrigin.End }
 Specifies the position in a stream to use for seeking. More...
 
enum  WatcherChangeTypes {
  WatcherChangeTypes.Created = 0x1, WatcherChangeTypes.Deleted = 0x2, WatcherChangeTypes.Changed = 0x4, WatcherChangeTypes.Renamed = 0x8,
  WatcherChangeTypes.All = 0xF
}
 Changes that might occur to a file or directory. More...
 

Functions

delegate void ErrorEventHandler (object sender, ErrorEventArgs e)
 Represents the method that will handle the E:System.IO.FileSystemWatcher.Error event of a T:System.IO.FileSystemWatcher object. More...
 
delegate void FileSystemEventHandler (object sender, FileSystemEventArgs e)
 Represents the method that will handle the E:System.IO.FileSystemWatcher.Changed, E:System.IO.FileSystemWatcher.Created, or E:System.IO.FileSystemWatcher.Deleted event of a T:System.IO.FileSystemWatcher class. More...
 
delegate void RenamedEventHandler (object sender, RenamedEventArgs e)
 Represents the method that will handle the E:System.IO.FileSystemWatcher.Renamed event of a T:System.IO.FileSystemWatcher class. More...
 

Enumeration Type Documentation

◆ DriveType

enum System.IO.DriveType
strong

Defines constants for drive types, including CDRom, Fixed, Network, NoRootDirectory, Ram, Removable, and Unknown.

Enumerator
Unknown 

The type of drive is unknown.

NoRootDirectory 

The drive does not have a root directory.

Removable 

The drive is a removable storage device, such as a floppy disk drive or a USB flash drive.

Fixed 

The drive is a fixed disk.

Network 

The drive is a network drive.

CDRom 

The drive is an optical disc device, such as a CD or DVD-ROM.

Ram 

The drive is a RAM disk.

Definition at line 8 of file DriveType.cs.

◆ FileAccess

enum System.IO.FileAccess
strong

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

Enumerator
Read 

Read access to the file. Data can be read from the file. Combine with Write for read/write access.

Write 

Write access to the file. Data can be written to the file. Combine with Read for read/write access.

ReadWrite 

Read and write access to the file. Data can be written to and read from the file.

Definition at line 9 of file FileAccess.cs.

◆ FileAttributes

Provides attributes for files and directories.

Enumerator
ReadOnly 

The file is read-only.

Hidden 

The file is hidden, and thus is not included in an ordinary directory listing.

System 

The file is a system file. That is, the file is part of the operating system or is used exclusively by the operating system.

Directory 

The file is a directory.

Archive 

The file is a candidate for backup or removal.

Device 

Reserved for future use.

Normal 

The file is a standard file that has no special attributes. This attribute is valid only if it is used alone.

Temporary 

The file is temporary. A temporary file contains data that is needed while an application is executing but is not needed after the application is finished. File systems try to keep all the data in memory for quicker access rather than flushing the data back to mass storage. A temporary file should be deleted by the application as soon as it is no longer needed.

SparseFile 

The file is a sparse file. Sparse files are typically large files whose data consists of mostly zeros.

ReparsePoint 

The file contains a reparse point, which is a block of user-defined data associated with a file or a directory.

Compressed 

The file is compressed.

Offline 

The file is offline. The data of the file is not immediately available.

NotContentIndexed 

The file will not be indexed by the operating system's content indexing service.

Encrypted 

The file or directory is encrypted. For a file, this means that all data in the file is encrypted. For a directory, this means that encryption is the default for newly created files and directories.

IntegrityStream 

The file or directory includes data integrity support. When this value is applied to a file, all data streams in the file have integrity support. When this value is applied to a directory, all new files and subdirectories within that directory, by default, include integrity support.

NoScrubData 

The file or directory is excluded from the data integrity scan. When this value is applied to a directory, by default, all new files and subdirectories within that directory are excluded from data integrity.

Definition at line 9 of file FileAttributes.cs.

◆ FileMode

enum System.IO.FileMode
strong

Specifies how the operating system should open a file.

Enumerator
CreateNew 

Specifies that the operating system should create a new file. This requires F:System.Security.Permissions.FileIOPermissionAccess.Write permission. If the file already exists, an T:System.IO.IOException exception is thrown.

Create 

Specifies that the operating system should create a new file. If the file already exists, it will be overwritten. This requires F:System.Security.Permissions.FileIOPermissionAccess.Write permission. FileMode.Create is equivalent to requesting that if the file does not exist, use F:System.IO.FileMode.CreateNew; otherwise, use F:System.IO.FileMode.Truncate. If the file already exists but is a hidden file, an T:System.UnauthorizedAccessException exception is thrown.

Open 

Specifies that the operating system should open an existing file. The ability to open the file is dependent on the value specified by the T:System.IO.FileAccess enumeration. A T:System.IO.FileNotFoundException exception is thrown if the file does not exist.

OpenOrCreate 

Specifies that the operating system should open a file if it exists; otherwise, a new file should be created. If the file is opened with FileAccess.Read, F:System.Security.Permissions.FileIOPermissionAccess.Read permission is required. If the file access is FileAccess.Write, F:System.Security.Permissions.FileIOPermissionAccess.Write permission is required. If the file is opened with FileAccess.ReadWrite, both F:System.Security.Permissions.FileIOPermissionAccess.Read and F:System.Security.Permissions.FileIOPermissionAccess.Write permissions are required.

Truncate 

Specifies that the operating system should open an existing file. When the file is opened, it should be truncated so that its size is zero bytes. This requires F:System.Security.Permissions.FileIOPermissionAccess.Write permission. Attempts to read from a file opened with FileMode.Truncate cause an T:System.ArgumentException exception.

Append 

Opens the file if it exists and seeks to the end of the file, or creates a new file. This requires F:System.Security.Permissions.FileIOPermissionAccess.Append permission. FileMode.Append can be used only in conjunction with FileAccess.Write. Trying to seek to a position before the end of the file throws an T:System.IO.IOException exception, and any attempt to read fails and throws a T:System.NotSupportedException exception.

Definition at line 8 of file FileMode.cs.

◆ FileOptions

enum System.IO.FileOptions
strong

Represents advanced options for creating a T:System.IO.FileStream object.

Enumerator
None 

Indicates that no additional options should be used when creating a T:System.IO.FileStream object.

WriteThrough 

Indicates that the system should write through any intermediate cache and go directly to disk.

Asynchronous 

Indicates that a file can be used for asynchronous reading and writing.

RandomAccess 

Indicates that the file is accessed randomly. The system can use this as a hint to optimize file caching.

DeleteOnClose 

Indicates that a file is automatically deleted when it is no longer in use.

SequentialScan 

Indicates that the file is to be accessed sequentially from beginning to end. The system can use this as a hint to optimize file caching. If an application moves the file pointer for random access, optimum caching may not occur; however, correct operation is still guaranteed.

Encrypted 

Indicates that a file is encrypted and can be decrypted only by using the same user account used for encryption.

Definition at line 9 of file FileOptions.cs.

◆ FileShare

enum System.IO.FileShare
strong

Contains constants for controlling the kind of access other T:System.IO.FileStream objects can have to the same file.

Enumerator
None 

Declines sharing of the current file. Any request to open the file (by this process or another process) will fail until the file is closed.

Read 

Allows subsequent opening of the file for reading. If this flag is not specified, any request to open the file for reading (by this process or another process) will fail until the file is closed. However, even if this flag is specified, additional permissions might still be needed to access the file.

Write 

Allows subsequent opening of the file for writing. If this flag is not specified, any request to open the file for writing (by this process or another process) will fail until the file is closed. However, even if this flag is specified, additional permissions might still be needed to access the file.

ReadWrite 

Allows subsequent opening of the file for reading or writing. If this flag is not specified, any request to open the file for reading or writing (by this process or another process) will fail until the file is closed. However, even if this flag is specified, additional permissions might still be needed to access the file.

Delete 

Allows subsequent deleting of a file.

Inheritable 

Makes the file handle inheritable by child processes. This is not directly supported by Win32.

Definition at line 9 of file FileShare.cs.

◆ HandleInheritability

Specifies whether the underlying handle is inheritable by child processes.

Enumerator
None 

Specifies that the handle is not inheritable by child processes.

Inheritable 

Specifies that the handle is inheritable by child processes.

Definition at line 6 of file HandleInheritability.cs.

◆ NotifyFilters

Specifies changes to watch for in a file or folder.

Enumerator
FileName 

The name of the file.

DirectoryName 

The name of the directory.

Attributes 

The attributes of the file or folder.

Size 

The size of the file or folder.

LastWrite 

The date the file or folder last had anything written to it.

LastAccess 

The date the file or folder was last opened.

CreationTime 

The time the file or folder was created.

Security 

The security settings of the file or folder.

Definition at line 5 of file NotifyFilters.cs.

◆ SearchOption

Specifies whether to search the current directory, or the current directory and all subdirectories.

Enumerator
TopDirectoryOnly 

Includes only the current directory in a search operation.

AllDirectories 

Includes the current directory and all its subdirectories in a search operation. This option includes reparse points such as mounted drives and symbolic links in the search.

Definition at line 8 of file SearchOption.cs.

◆ SeekOrigin

enum System.IO.SeekOrigin
strong

Specifies the position in a stream to use for seeking.

Enumerator
Begin 

Specifies the beginning of a stream.

Current 

Specifies the current position within a stream.

End 

Specifies the end of a stream.

Definition at line 9 of file SeekOrigin.cs.

◆ WatcherChangeTypes

Changes that might occur to a file or directory.

Enumerator
Created 

The creation of a file or folder.

Deleted 

The deletion of a file or folder.

Changed 

The change of a file or folder. The types of changes include: changes to size, attributes, security settings, last write, and last access time.

Renamed 

The renaming of a file or folder.

All 

The creation, deletion, change, or renaming of a file or folder.

Definition at line 5 of file WatcherChangeTypes.cs.

Function Documentation

◆ ErrorEventHandler()

delegate void System.IO.ErrorEventHandler ( object  sender,
ErrorEventArgs  e 
)

Represents the method that will handle the E:System.IO.FileSystemWatcher.Error event of a T:System.IO.FileSystemWatcher object.

Parameters
senderThe source of the event.
eAn T:System.IO.ErrorEventArgs object that contains the event data.

◆ FileSystemEventHandler()

delegate void System.IO.FileSystemEventHandler ( object  sender,
FileSystemEventArgs  e 
)

Represents the method that will handle the E:System.IO.FileSystemWatcher.Changed, E:System.IO.FileSystemWatcher.Created, or E:System.IO.FileSystemWatcher.Deleted event of a T:System.IO.FileSystemWatcher class.

Parameters
senderThe source of the event.
eThe T:System.IO.FileSystemEventArgs that contains the event data.

◆ RenamedEventHandler()

delegate void System.IO.RenamedEventHandler ( object  sender,
RenamedEventArgs  e 
)

Represents the method that will handle the E:System.IO.FileSystemWatcher.Renamed event of a T:System.IO.FileSystemWatcher class.

Parameters
senderThe source of the event.
eThe T:System.IO.RenamedEventArgs that contains the event data.