System.IO.FileSystem
Represents a wrapper class for a file handle.
Initializes a new instance of the class.
An object that represents the pre-existing handle to use.
true to reliably release the handle during the finalization phase; false to prevent reliable release (not recommended).
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.
1
Creates all directories and subdirectories in the specified path unless they already exist.
An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists.
The directory to create.
The directory specified by is a file.-or-The network name is not known.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the method.-or- is prefixed with, or contains, only a colon character (:).
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The specified path is invalid (for example, it is on an unmapped drive).
contains a colon character (:) that is not part of a drive label ("C:\").
1
Deletes an empty directory from a specified path.
The name of the empty directory to remove. This directory must be writable and empty.
A file with the same name and location specified by exists.-or-The directory is the application's current working directory.-or-The directory specified by is not empty.-or-The directory is read-only or contains a read-only file.-or-The directory is being used by another process.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the method.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
does not exist or could not be found.-or-The specified path is invalid (for example, it is on an unmapped drive).
1
Deletes the specified directory and, if indicated, any subdirectories and files in the directory.
The name of the directory to remove.
true to remove directories, subdirectories, and files in ; otherwise, false.
A file with the same name and location specified by exists.-or-The directory specified by is read-only, or is false and is not an empty directory. -or-The directory is the application's current working directory. -or-The directory contains a read-only file.-or-The directory is being used by another process.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the method.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
does not exist or could not be found.-or-The specified path is invalid (for example, it is on an unmapped drive).
1
Returns an enumerable collection of directory names in a specified path.
An enumerable collection of the full names (including paths) for the directories in the directory specified by .
The relative or absolute path to the directory to search. This string is not case-sensitive.
is a zero-length string, contains only white space, or contains invalid characters. You can query for invalid characters by using the method.
is null.
is invalid, such as referring to an unmapped drive.
is a file name.
The specified path, file name, or combined exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The caller does not have the required permission.
The caller does not have the required permission.
Returns an enumerable collection of directory names that match a search pattern in a specified path.
An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified search pattern.
The relative or absolute path to the directory to search. This string is not case-sensitive.
The search string to match against the names of directories in . This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions.
is a zero-length string, contains only white space, or contains invalid characters. You can query for invalid characters with the method.- or - does not contain a valid pattern.
is null.-or- is null.
is invalid, such as referring to an unmapped drive.
is a file name.
The specified path, file name, or combined exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The caller does not have the required permission.
The caller does not have the required permission.
Returns an enumerable collection of directory names that match a search pattern in a specified path, and optionally searches subdirectories.
An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified search pattern and option.
The relative or absolute path to the directory to search. This string is not case-sensitive.
The search string to match against the names of directories in . This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions.
One of the enumeration values that specifies whether the search operation should include only the current directory or should include all subdirectories.The default value is .
is a zero-length string, contains only white space, or contains invalid characters. You can query for invalid characters by using the method.- or - does not contain a valid pattern.
is null.-or- is null.
is not a valid value.
is invalid, such as referring to an unmapped drive.
is a file name.
The specified path, file name, or combined exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The caller does not have the required permission.
The caller does not have the required permission.
Returns an enumerable collection of file names in a specified path.
An enumerable collection of the full names (including paths) for the files in the directory specified by .
The relative or absolute path to the directory to search. This string is not case-sensitive.
is a zero-length string, contains only white space, or contains invalid characters. You can query for invalid characters by using the method.
is null.
is invalid, such as referring to an unmapped drive.
is a file name.
The specified path, file name, or combined exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The caller does not have the required permission.
The caller does not have the required permission.
Returns an enumerable collection of file names that match a search pattern in a specified path.
An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the specified search pattern.
The relative or absolute path to the directory to search. This string is not case-sensitive.
The search string to match against the names of files in . This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions.
is a zero-length string, contains only white space, or contains invalid characters. You can query for invalid characters by using the method.- or - does not contain a valid pattern.
is null.-or- is null.
is invalid, such as referring to an unmapped drive.
is a file name.
The specified path, file name, or combined exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The caller does not have the required permission.
The caller does not have the required permission.
Returns an enumerable collection of file names that match a search pattern in a specified path, and optionally searches subdirectories.
An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the specified search pattern and option.
The relative or absolute path to the directory to search. This string is not case-sensitive.
The search string to match against the names of files in . This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions.
One of the enumeration values that specifies whether the search operation should include only the current directory or should include all subdirectories.The default value is .
is a zero-length string, contains only white space, or contains invalid characters. You can query for invalid characters by using the method.- or - does not contain a valid pattern.
is null.-or- is null.
is not a valid value.
is invalid, such as referring to an unmapped drive.
is a file name.
The specified path, file name, or combined exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The caller does not have the required permission.
The caller does not have the required permission.
Returns an enumerable collection of file names and directory names in a specified path.
An enumerable collection of file-system entries in the directory specified by .
The relative or absolute path to the directory to search. This string is not case-sensitive.
is a zero-length string, contains only white space, or contains invalid characters. You can query for invalid characters by using the method.
is null.
is invalid, such as referring to an unmapped drive.
is a file name.
The specified path, file name, or combined exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The caller does not have the required permission.
The caller does not have the required permission.
Returns an enumerable collection of file names and directory names that match a search pattern in a specified path.
An enumerable collection of file-system entries in the directory specified by and that match the specified search pattern.
The relative or absolute path to the directory to search. This string is not case-sensitive.
The search string to match against the names of file-system entries in . This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions.
is a zero-length string, contains only white space, or contains invalid characters. You can query for invalid characters by using the method.- or - does not contain a valid pattern.
is null.-or- is null.
is invalid, such as referring to an unmapped drive.
is a file name.
The specified path, file name, or combined exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The caller does not have the required permission.
The caller does not have the required permission.
Returns an enumerable collection of file names and directory names that match a search pattern in a specified path, and optionally searches subdirectories.
An enumerable collection of file-system entries in the directory specified by and that match the specified search pattern and option.
The relative or absolute path to the directory to search. This string is not case-sensitive.
The search string to match against file-system entries in . This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions.
One of the enumeration values that specifies whether the search operation should include only the current directory or should include all subdirectories.The default value is .
is a zero-length string, contains only white space, or contains invalid characters. You can query for invalid characters by using the method.- or - does not contain a valid pattern.
is null.-or- is null.
is not a valid value.
is invalid, such as referring to an unmapped drive.
is a file name.
The specified path, file name, or combined exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The caller does not have the required permission.
The caller does not have the required permission.
Determines whether the given path refers to an existing directory on disk.
true if refers to an existing directory; false if the directory does not exist or an error occurs when trying to determine if the specified file exists.
The path to test.
1
Gets the creation date and time of a directory.
A structure that is set to the creation date and time for the specified directory. This value is expressed in local time.
The path of the directory.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the method.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
1
Gets the creation date and time, in Coordinated Universal Time (UTC) format, of a directory.
A structure that is set to the creation date and time for the specified directory. This value is expressed in UTC time.
The path of the directory.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the method.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
2
Gets the current working directory of the application.
A string that contains the path of the current working directory, and does not end with a backslash (\).
The caller does not have the required permission.
The operating system is Windows CE, which does not have current directory functionality.This method is available in the .NET Compact Framework, but is not currently supported.
1
Returns the names of subdirectories (including their paths) in the specified directory.
An array of the full names (including paths) of subdirectories in the specified path, or an empty array if no directories are found.
The relative or absolute path to the directory to search. This string is not case-sensitive.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the method.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
is a file name.
The specified path is invalid (for example, it is on an unmapped drive).
1
Returns the names of subdirectories (including their paths) that match the specified search pattern in the specified directory.
An array of the full names (including paths) of the subdirectories that match the search pattern in the specified directory, or an empty array if no directories are found.
The relative or absolute path to the directory to search. This string is not case-sensitive.
The search string to match against the names of subdirectories in . This parameter can contain a combination of valid literal and wildcard characters (see Remarks), but doesn't support regular expressions.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using .-or- doesn't contain a valid pattern.
or is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
is a file name.
The specified path is invalid (for example, it is on an unmapped drive).
1
Returns the names of the subdirectories (including their paths) that match the specified search pattern in the specified directory, and optionally searches subdirectories.
An array of the full names (including paths) of the subdirectories that match the specified criteria, or an empty array if no directories are found.
The relative or absolute path to the directory to search. This string is not case-sensitive.
The search string to match against the names of subdirectories in . This parameter can contain a combination of valid literal and wildcard characters (see Remarks), but doesn't support regular expressions.
One of the enumeration values that specifies whether the search operation should include all subdirectories or only the current directory.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the method.-or- does not contain a valid pattern.
or is null.
is not a valid value.
The caller does not have the required permission.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
is a file name.
The specified path is invalid (for example, it is on an unmapped drive).
Returns the volume information, root information, or both for the specified path.
A string that contains the volume information, root information, or both for the specified path.
The path of a file or directory.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters with .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
1
Returns the names of files (including their paths) in the specified directory.
An array of the full names (including paths) for the files in the specified directory, or an empty array if no files are found.
The relative or absolute path to the directory to search. This string is not case-sensitive.
is a file name.-or-A network error has occurred.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the method.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The specified path is not found or is invalid (for example, it is on an unmapped drive).
1
Returns the names of files (including their paths) that match the specified search pattern in the specified directory.
An array of the full names (including paths) for the files in the specified directory that match the specified search pattern, or an empty array if no files are found.
The relative or absolute path to the directory to search. This string is not case-sensitive.
The search string to match against the names of files in . This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions.
is a file name.-or-A network error has occurred.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using .-or- doesn't contain a valid pattern.
or is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The specified path is not found or is invalid (for example, it is on an unmapped drive).
1
Returns the names of files (including their paths) that match the specified search pattern in the specified directory, using a value to determine whether to search subdirectories.
An array of the full names (including paths) for the files in the specified directory that match the specified search pattern and option, or an empty array if no files are found.
The relative or absolute path to the directory to search. This string is not case-sensitive.
The search string to match against the names of files in . This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions.
One of the enumeration values that specifies whether the search operation should include all subdirectories or only the current directory.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters with the method. -or- does not contain a valid pattern.
or is null.
is not a valid value.
The caller does not have the required permission.
The specified path is not found or is invalid (for example, it is on an unmapped drive).
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
is a file name.-or-A network error has occurred.
Returns the names of all files and subdirectories in a specified path.
An array of the names of files and subdirectories in the specified directory, or an empty array if no files or subdirectories are found.
The relative or absolute path to the directory to search. This string is not case-sensitive.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters with .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
is a file name.
The specified path is invalid (for example, it is on an unmapped drive).
1
Returns an array of file names and directory names that that match a search pattern in a specified path.
An array of file names and directory names that match the specified search criteria, or an empty array if no files or directories are found.
The relative or absolute path to the directory to search. This string is not case-sensitive.
The search string to match against the names of file and directories in . This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters with the method.-or- does not contain a valid pattern.
or is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
is a file name.
The specified path is invalid (for example, it is on an unmapped drive).
1
Returns an array of all the file names and directory names that match a search pattern in a specified path, and optionally searches subdirectories.
An array of file the file names and directory names that match the specified search criteria, or an empty array if no files or directories are found.
The relative or absolute path to the directory to search. This string is not case-sensitive.
The search string to match against the names of files and directories in . This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions.
One of the enumeration values that specifies whether the search operation should include only the current directory or should include all subdirectories.The default value is .
is a zero-length string, contains only white space, or contains invalid characters. You can query for invalid characters by using the method.- or - does not contain a valid pattern.
is null.-or- is null.
is not a valid value.
is invalid, such as referring to an unmapped drive.
is a file name.
The specified path, file name, or combined exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The caller does not have the required permission.
The caller does not have the required permission.
Returns the date and time the specified file or directory was last accessed.
A structure that is set to the date and time the specified file or directory was last accessed. This value is expressed in local time.
The file or directory for which to obtain access date and time information.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters with the method.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The parameter is in an invalid format.
1
Returns the date and time, in Coordinated Universal Time (UTC) format, that the specified file or directory was last accessed.
A structure that is set to the date and time the specified file or directory was last accessed. This value is expressed in UTC time.
The file or directory for which to obtain access date and time information.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters with the method.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The parameter is in an invalid format.
1
Returns the date and time the specified file or directory was last written to.
A structure that is set to the date and time the specified file or directory was last written to. This value is expressed in local time.
The file or directory for which to obtain modification date and time information.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters with the method.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
1
Returns the date and time, in Coordinated Universal Time (UTC) format, that the specified file or directory was last written to.
A structure that is set to the date and time the specified file or directory was last written to. This value is expressed in UTC time.
The file or directory for which to obtain modification date and time information.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters with the method.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
2
Retrieves the parent directory of the specified path, including both absolute and relative paths.
The parent directory, or null if is the root directory, including the root of a UNC server or share name.
The path for which to retrieve the parent directory.
The directory specified by is read-only.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters with the method.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The specified path was not found.
1
Moves a file or a directory and its contents to a new location.
The path of the file or directory to move.
The path to the new location for . If is a file, then must also be a file name.
An attempt was made to move a directory to a different volume. -or- already exists. -or- The and parameters refer to the same file or directory. -or-The directory or a file within it is being used by another process.
The caller does not have the required permission.
or is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters with the method.
or is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The path specified by is invalid (for example, it is on an unmapped drive).
1
Sets the creation date and time for the specified file or directory.
The file or directory for which to set the creation date and time information.
The date and time the file or directory was last written to. This value is expressed in local time.
The specified path was not found.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters with the method.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The caller does not have the required permission.
specifies a value outside the range of dates or times permitted for this operation.
The current operating system is not Windows NT or later.
1
Sets the creation date and time, in Coordinated Universal Time (UTC) format, for the specified file or directory.
The file or directory for which to set the creation date and time information.
The date and time the directory or file was created. This value is expressed in local time.
The specified path was not found.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters with the method.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The caller does not have the required permission.
specifies a value outside the range of dates or times permitted for this operation.
The current operating system is not Windows NT or later.
2
Sets the application's current working directory to the specified directory.
The path to which the current working directory is set.
An I/O error occurred.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters with the method.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The caller does not have the required permission to access unmanaged code.
The specified path was not found.
The specified directory was not found.
1
Sets the date and time the specified file or directory was last accessed.
The file or directory for which to set the access date and time information.
An object that contains the value to set for the access date and time of . This value is expressed in local time.
The specified path was not found.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters with the method.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The caller does not have the required permission.
The current operating system is not Windows NT or later.
specifies a value outside the range of dates or times permitted for this operation.
1
Sets the date and time, in Coordinated Universal Time (UTC) format, that the specified file or directory was last accessed.
The file or directory for which to set the access date and time information.
An object that contains the value to set for the access date and time of . This value is expressed in UTC time.
The specified path was not found.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters with the method.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The caller does not have the required permission.
The current operating system is not Windows NT or later.
specifies a value outside the range of dates or times permitted for this operation.
1
Sets the date and time a directory was last written to.
The path of the directory.
The date and time the directory was last written to. This value is expressed in local time.
The specified path was not found.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters with the method.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The caller does not have the required permission.
The current operating system is not Windows NT or later.
specifies a value outside the range of dates or times permitted for this operation.
1
Sets the date and time, in Coordinated Universal Time (UTC) format, that a directory was last written to.
The path of the directory.
The date and time the directory was last written to. This value is expressed in UTC time.
The specified path was not found.
is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters with the method.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The caller does not have the required permission.
The current operating system is not Windows NT or later.
specifies a value outside the range of dates or times permitted for this operation.
2
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.
1
Initializes a new instance of the class on the specified path.
A string specifying the path on which to create the DirectoryInfo.
is null.
The caller does not have the required permission.
contains invalid characters such as ", <, >, or |.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. The specified path, file name, or both are too long.
Creates a directory.
The directory cannot be created.
1
Creates a subdirectory or subdirectories on the specified path. The specified path can be relative to this instance of the class.
The last directory specified in .
The specified path. This cannot be a different disk volume or Universal Naming Convention (UNC) name.
does not specify a valid file path or contains invalid DirectoryInfo characters.
is null.
The specified path is invalid, such as being on an unmapped drive.
The subdirectory cannot be created.-or- A file or directory already has the name specified by .
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. The specified path, file name, or both are too long.
The caller does not have code access permission to create the directory.-or-The caller does not have code access permission to read the directory described by the returned object. This can occur when the parameter describes an existing directory.
contains a colon character (:) that is not part of a drive label ("C:\").
2
Deletes this if it is empty.
The directory contains a read-only file.
The directory described by this object does not exist or could not be found.
The directory is not empty. -or-The directory is the application's current working directory.-or-There is an open handle on the directory, and the operating system is Windows XP or earlier. This open handle can result from enumerating directories. For more information, see How to: Enumerate Directories and Files.
The caller does not have the required permission.
1
Deletes this instance of a , specifying whether to delete subdirectories and files.
true to delete this directory, its subdirectories, and all files; otherwise, false.
The directory contains a read-only file.
The directory described by this object does not exist or could not be found.
The directory is read-only.-or- The directory contains one or more files or subdirectories and is false.-or-The directory is the application's current working directory. -or-There is an open handle on the directory or on one of its files, and the operating system is Windows XP or earlier. This open handle can result from enumerating directories and files. For more information, see How to: Enumerate Directories and Files.
The caller does not have the required permission.
1
Returns an enumerable collection of directory information in the current directory.
An enumerable collection of directories in the current directory.
The path encapsulated in the object is invalid (for example, it is on an unmapped drive).
The caller does not have the required permission.
Returns an enumerable collection of directory information that matches a specified search pattern.
An enumerable collection of directories that matches .
The search string to match against the names of directories. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions. The default pattern is "*", which returns all files.
is null.
The path encapsulated in the object is invalid (for example, it is on an unmapped drive).
The caller does not have the required permission.
Returns an enumerable collection of directory information that matches a specified search pattern and search subdirectory option.
An enumerable collection of directories that matches and .
The search string to match against the names of directories. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions. The default pattern is "*", which returns all files.
One of the enumeration values that specifies whether the search operation should include only the current directory or all subdirectories. The default value is .
is null.
is not a valid value.
The path encapsulated in the object is invalid (for example, it is on an unmapped drive).
The caller does not have the required permission.
Returns an enumerable collection of file information in the current directory.
An enumerable collection of the files in the current directory.
The path encapsulated in the object is invalid (for example, it is on an unmapped drive).
The caller does not have the required permission.
Returns an enumerable collection of file information that matches a search pattern.
An enumerable collection of files that matches .
The search string to match against the names of files. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions. The default pattern is "*", which returns all files.
is null.
The path encapsulated in the object is invalid, (for example, it is on an unmapped drive).
The caller does not have the required permission.
Returns an enumerable collection of file information that matches a specified search pattern and search subdirectory option.
An enumerable collection of files that matches and .
The search string to match against the names of files. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions. The default pattern is "*", which returns all files.
One of the enumeration values that specifies whether the search operation should include only the current directory or all subdirectories. The default value is .
is null.
is not a valid value.
The path encapsulated in the object is invalid (for example, it is on an unmapped drive).
The caller does not have the required permission.
Returns an enumerable collection of file system information in the current directory.
An enumerable collection of file system information in the current directory.
The path encapsulated in the object is invalid (for example, it is on an unmapped drive).
The caller does not have the required permission.
Returns an enumerable collection of file system information that matches a specified search pattern.
An enumerable collection of file system information objects that matches .
The search string to match against the names of directories. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions. The default pattern is "*", which returns all files.
is null.
The path encapsulated in the object is invalid (for example, it is on an unmapped drive).
The caller does not have the required permission.
Returns an enumerable collection of file system information that matches a specified search pattern and search subdirectory option.
An enumerable collection of file system information objects that matches and .
The search string to match against the names of directories. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions. The default pattern is "*", which returns all files.
One of the enumeration values that specifies whether the search operation should include only the current directory or all subdirectories. The default value is .
is null.
is not a valid value.
The path encapsulated in the object is invalid (for example, it is on an unmapped drive).
The caller does not have the required permission.
Gets a value indicating whether the directory exists.
true if the directory exists; otherwise, false.
1
Returns the subdirectories of the current directory.
An array of objects.
The path encapsulated in the object is invalid, such as being on an unmapped drive.
The caller does not have the required permission.
The caller does not have the required permission.
1
Returns an array of directories in the current matching the given search criteria.
An array of type DirectoryInfo matching .
The search string to match against the names of directories. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions. The default pattern is "*", which returns all files.
contains one or more invalid characters defined by the method.
is null.
The path encapsulated in the DirectoryInfo object is invalid (for example, it is on an unmapped drive).
The caller does not have the required permission.
1
Returns an array of directories in the current matching the given search criteria and using a value to determine whether to search subdirectories.
An array of type DirectoryInfo matching .
The search string to match against the names of directories. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions. The default pattern is "*", which returns all files.
One of the enumeration values that specifies whether the search operation should include only the current directory or all subdirectories.
contains one or more invalid characters defined by the method.
is null.
is not a valid value.
The path encapsulated in the DirectoryInfo object is invalid (for example, it is on an unmapped drive).
The caller does not have the required permission.
Returns a file list from the current directory.
An array of type .
The path is invalid, such as being on an unmapped drive.
1
Returns a file list from the current directory matching the given search pattern.
An array of type .
The search string to match against the names of files. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions. The default pattern is "*", which returns all files.
contains one or more invalid characters defined by the method.
is null.
The path is invalid (for example, it is on an unmapped drive).
The caller does not have the required permission.
1
Returns a file list from the current directory matching the given search pattern and using a value to determine whether to search subdirectories.
An array of type .
The search string to match against the names of files. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions. The default pattern is "*", which returns all files.
One of the enumeration values that specifies whether the search operation should include only the current directory or all subdirectories.
contains one or more invalid characters defined by the method.
is null.
is not a valid value.
The path is invalid (for example, it is on an unmapped drive).
The caller does not have the required permission.
Returns an array of strongly typed entries representing all the files and subdirectories in a directory.
An array of strongly typed entries.
The path is invalid (for example, it is on an unmapped drive).
2
Retrieves an array of strongly typed objects representing the files and subdirectories that match the specified search criteria.
An array of strongly typed FileSystemInfo objects matching the search criteria.
The search string to match against the names of directories and files. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions. The default pattern is "*", which returns all files.
contains one or more invalid characters defined by the method.
is null.
The specified path is invalid (for example, it is on an unmapped drive).
The caller does not have the required permission.
2
Retrieves an array of objects that represent the files and subdirectories matching the specified search criteria.
An array of file system entries that match the search criteria.
The search string to match against the names of directories and filesa. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions. The default pattern is "*", which returns all files.
One of the enumeration values that specifies whether the search operation should include only the current directory or all subdirectories. The default value is .
contains one or more invalid characters defined by the method.
is null.
is not a valid value.
The specified path is invalid (for example, it is on an unmapped drive).
The caller does not have the required permission.
Moves a instance and its contents to a new path.
The name and path to which to move this directory. The destination cannot be another disk volume or a directory with the identical name. It can be an existing directory to which you want to add this directory as a subdirectory.
is null.
is an empty string (''").
An attempt was made to move a directory to a different volume. -or- already exists.-or-You are not authorized to access this path.-or- The directory being moved and the destination directory have the same name.
The caller does not have the required permission.
The destination directory cannot be found.
1
Gets the name of this instance.
The directory name.
1
Gets the parent directory of a specified subdirectory.
The parent directory, or null if the path is null or if the file path denotes a root (such as "\", "C:", or * "\\server\share").
The caller does not have the required permission.
1
Gets the root portion of the directory.
An object that represents the root of the directory.
The caller does not have the required permission.
1
Returns the original path that was passed by the user.
Returns the original path that was passed by the user.
2
Provides static methods for the creation, copying, deletion, moving, and opening of a single file, and aids in the creation of objects.To browse the .NET Framework source code for this type, see the Reference Source.
1
Appends lines to a file, and then closes the file. If the specified file does not exist, this method creates a file, writes the specified lines to the file, and then closes the file.
The file to append the lines to. The file is created if it doesn't already exist.
The lines to append to the file.
is a zero-length string, contains only white space, or contains one more invalid characters defined by the method.
Eitheror is null.
is invalid (for example, the directory doesn’t exist or it is on an unmapped drive).
The file specified by was not found.
An I/O error occurred while opening the file.
exceeds the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
is in an invalid format.
The caller does not have permission to write to the file.
specifies a file that is read-only.-or-This operation is not supported on the current platform.-or- is a directory.
Appends lines to a file by using a specified encoding, and then closes the file. If the specified file does not exist, this method creates a file, writes the specified lines to the file, and then closes the file.
The file to append the lines to. The file is created if it doesn't already exist.
The lines to append to the file.
The character encoding to use.
is a zero-length string, contains only white space, or contains one more invalid characters defined by the method.
Either, , or is null.
is invalid (for example, the directory doesn’t exist or it is on an unmapped drive).
The file specified by was not found.
An I/O error occurred while opening the file.
exceeds the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
is in an invalid format.
The caller does not have the required permission.
specifies a file that is read-only.-or-This operation is not supported on the current platform.-or- is a directory.-or-The caller does not have the required permission.
Opens a file, appends the specified string to the file, and then closes the file. If the file does not exist, this method creates a file, writes the specified string to the file, then closes the file.
The file to append the specified string to.
The string to append to the file.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid (for example, the directory doesn’t exist or it is on an unmapped drive).
An I/O error occurred while opening the file.
specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission.
is in an invalid format.
The caller does not have the required permission.
1
Appends the specified string to the file, creating the file if it does not already exist.
The file to append the specified string to.
The string to append to the file.
The character encoding to use.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid (for example, the directory doesn’t exist or it is on an unmapped drive).
An I/O error occurred while opening the file.
specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission.
is in an invalid format.
The caller does not have the required permission.
1
Creates a that appends UTF-8 encoded text to an existing file, or to a new file if the specified file does not exist.
A stream writer that appends UTF-8 encoded text to the specified file or to a new file.
The path to the file to append to.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid (for example, the directory doesn’t exist or it is on an unmapped drive).
is in an invalid format.
1
Copies an existing file to a new file. Overwriting a file of the same name is not allowed.
The file to copy.
The name of the destination file. This cannot be a directory or an existing file.
The caller does not have the required permission.
or is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .-or- or specifies a directory.
or is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The path specified in or is invalid (for example, it is on an unmapped drive).
was not found.
exists.-or- An I/O error has occurred.
or is in an invalid format.
1
Copies an existing file to a new file. Overwriting a file of the same name is allowed.
The file to copy.
The name of the destination file. This cannot be a directory.
true if the destination file can be overwritten; otherwise, false.
The caller does not have the required permission. -or- is read-only.
or is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .-or- or specifies a directory.
or is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The path specified in or is invalid (for example, it is on an unmapped drive).
was not found.
exists and is false.-or- An I/O error has occurred.
or is in an invalid format.
1
Creates or overwrites a file in the specified path.
A that provides read/write access to the file specified in .
The path and name of the file to create.
The caller does not have the required permission.-or- specified a file that is read-only.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid (for example, it is on an unmapped drive).
An I/O error occurred while creating the file.
is in an invalid format.
1
Creates or overwrites the specified file.
A with the specified buffer size that provides read/write access to the file specified in .
The name of the file.
The number of bytes buffered for reads and writes to the file.
The caller does not have the required permission.-or- specified a file that is read-only.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid (for example, it is on an unmapped drive).
An I/O error occurred while creating the file.
is in an invalid format.
1
Creates or overwrites the specified file, specifying a buffer size and a value that describes how to create or overwrite the file.
A new file with the specified buffer size.
The name of the file.
The number of bytes buffered for reads and writes to the file.
One of the values that describes how to create or overwrite the file.
The caller does not have the required permission.-or- specified a file that is read-only. -or- is specified for and file encryption is not supported on the current platform.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid (for example, it is on an unmapped drive.
An I/O error occurred while creating the file.
is in an invalid format.
The caller does not have the required permission.-or- specified a file that is read-only.
The caller does not have the required permission.-or- specified a file that is read-only.
Creates or opens a file for writing UTF-8 encoded text.
A that writes to the specified file using UTF-8 encoding.
The file to be opened for writing.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid (for example, it is on an unmapped drive).
is in an invalid format.
1
Deletes the specified file.
The name of the file to be deleted. Wildcard characters are not supported.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path is invalid (for example, it is on an unmapped drive).
The specified file is in use. -or-There is an open handle on the file, and the operating system is Windows XP or earlier. This open handle can result from enumerating directories and files. For more information, see How to: Enumerate Directories and Files.
is in an invalid format.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The caller does not have the required permission.-or- The file is an executable file that is in use.-or- is a directory.-or- specified a read-only file.
1
Determines whether the specified file exists.
true if the caller has the required permissions and contains the name of an existing file; otherwise, false. This method also returns false if is null, an invalid path, or a zero-length string. If the caller does not have sufficient permissions to read the specified file, no exception is thrown and the method returns false regardless of the existence of .
The file to check.
1
Gets the of the file on the path.
The of the file on the path.
The path to the file.
is empty, contains only white spaces, or contains invalid characters.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
is in an invalid format.
represents a file and is invalid, such as being on an unmapped drive, or the file cannot be found.
represents a directory and is invalid, such as being on an unmapped drive, or the directory cannot be found.
This file is being used by another process.
The caller does not have the required permission.
1
Returns the creation date and time of the specified file or directory.
A structure set to the creation date and time for the specified file or directory. This value is expressed in local time.
The file or directory for which to obtain creation date and time information.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
is in an invalid format.
1
Returns the creation date and time, in coordinated universal time (UTC), of the specified file or directory.
A structure set to the creation date and time for the specified file or directory. This value is expressed in UTC time.
The file or directory for which to obtain creation date and time information.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
is in an invalid format.
2
Returns the date and time the specified file or directory was last accessed.
A structure set to the date and time that the specified file or directory was last accessed. This value is expressed in local time.
The file or directory for which to obtain access date and time information.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
is in an invalid format.
1
Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last accessed.
A structure set to the date and time that the specified file or directory was last accessed. This value is expressed in UTC time.
The file or directory for which to obtain access date and time information.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
is in an invalid format.
1
Returns the date and time the specified file or directory was last written to.
A structure set to the date and time that the specified file or directory was last written to. This value is expressed in local time.
The file or directory for which to obtain write date and time information.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
is in an invalid format.
1
Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last written to.
A structure set to the date and time that the specified file or directory was last written to. This value is expressed in UTC time.
The file or directory for which to obtain write date and time information.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
is in an invalid format.
2
Moves a specified file to a new location, providing the option to specify a new file name.
The name of the file to move. Can include a relative or absolute path.
The new path and name for the file.
The destination file already exists.-or- was not found.
or is null.
or is a zero-length string, contains only white space, or contains invalid characters as defined in .
The caller does not have the required permission.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The path specified in or is invalid, (for example, it is on an unmapped drive).
or is in an invalid format.
1
Opens a on the specified path with read/write access.
A opened in the specified mode and path, with read/write access and not shared.
The file to open.
A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid, (for example, it is on an unmapped drive).
An I/O error occurred while opening the file.
specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission. -or- is and the specified file is a hidden file.
specified an invalid value.
The file specified in was not found.
is in an invalid format.
1
Opens a on the specified path, with the specified mode and access.
An unshared that provides access to the specified file, with the specified mode and access.
The file to open.
A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten.
A value that specifies the operations that can be performed on the file.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .-or- specified Read and specified Create, CreateNew, Truncate, or Append.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid, (for example, it is on an unmapped drive).
An I/O error occurred while opening the file.
specified a file that is read-only and is not Read.-or- specified a directory.-or- The caller does not have the required permission. -or- is and the specified file is a hidden file.
or specified an invalid value.
The file specified in was not found.
is in an invalid format.
1
Opens a on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option.
A on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option.
The file to open.
A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten.
A value that specifies the operations that can be performed on the file.
A value specifying the type of access other threads have to the file.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .-or- specified Read and specified Create, CreateNew, Truncate, or Append.
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid, (for example, it is on an unmapped drive).
An I/O error occurred while opening the file.
specified a file that is read-only and is not Read.-or- specified a directory.-or- The caller does not have the required permission. -or- is and the specified file is a hidden file.
, , or specified an invalid value.
The file specified in was not found.
is in an invalid format.
1
Opens an existing file for reading.
A read-only on the specified path.
The file to be opened for reading.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid, (for example, it is on an unmapped drive).
specified a directory.-or- The caller does not have the required permission.
The file specified in was not found.
is in an invalid format.
An I/O error occurred while opening the file.
1
Opens an existing UTF-8 encoded text file for reading.
A on the specified path.
The file to be opened for reading.
The caller does not have the required permission.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid, (for example, it is on an unmapped drive).
The file specified in was not found.
is in an invalid format.
1
Opens an existing file or creates a new file for writing.
An unshared object on the specified path with access.
The file to be opened for writing.
The caller does not have the required permission.-or- specified a read-only file or directory.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid, (for example, it is on an unmapped drive).
is in an invalid format.
1
Opens a binary file, reads the contents of the file into a byte array, and then closes the file.
A byte array containing the contents of the file.
The file to open for reading.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid (for example, it is on an unmapped drive).
An I/O error occurred while opening the file.
This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission.
The file specified in was not found.
is in an invalid format.
The caller does not have the required permission.
1
Opens a text file, reads all lines of the file, and then closes the file.
A string array containing all lines of the file.
The file to open for reading.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid (for example, it is on an unmapped drive).
An I/O error occurred while opening the file.
specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission.
The file specified in was not found.
is in an invalid format.
The caller does not have the required permission.
1
Opens a file, reads all lines of the file with the specified encoding, and then closes the file.
A string array containing all lines of the file.
The file to open for reading.
The encoding applied to the contents of the file.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid (for example, it is on an unmapped drive).
An I/O error occurred while opening the file.
specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission.
The file specified in was not found.
is in an invalid format.
The caller does not have the required permission.
1
Opens a text file, reads all lines of the file, and then closes the file.
A string containing all lines of the file.
The file to open for reading.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid (for example, it is on an unmapped drive).
An I/O error occurred while opening the file.
specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission.
The file specified in was not found.
is in an invalid format.
The caller does not have the required permission.
1
Opens a file, reads all lines of the file with the specified encoding, and then closes the file.
A string containing all lines of the file.
The file to open for reading.
The encoding applied to the contents of the file.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid (for example, it is on an unmapped drive).
An I/O error occurred while opening the file.
specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission.
The file specified in was not found.
is in an invalid format.
The caller does not have the required permission.
1
Reads the lines of a file.
All the lines of the file, or the lines that are the result of a query.
The file to read.
is a zero-length string, contains only white space, or contains one or more invalid characters defined by the method.
is null.
is invalid (for example, it is on an unmapped drive).
The file specified by was not found.
An I/O error occurred while opening the file.
exceeds the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The caller does not have the required permission.
specifies a file that is read-only.-or-This operation is not supported on the current platform.-or- is a directory.-or-The caller does not have the required permission.
Read the lines of a file that has a specified encoding.
All the lines of the file, or the lines that are the result of a query.
The file to read.
The encoding that is applied to the contents of the file.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by the method.
is null.
is invalid (for example, it is on an unmapped drive).
The file specified by was not found.
An I/O error occurred while opening the file.
exceeds the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
The caller does not have the required permission.
specifies a file that is read-only.-or-This operation is not supported on the current platform.-or- is a directory.-or-The caller does not have the required permission.
Sets the specified of the file on the specified path.
The path to the file.
A bitwise combination of the enumeration values.
is empty, contains only white spaces, contains invalid characters, or the file attribute is invalid.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
is in an invalid format.
The specified path is invalid, (for example, it is on an unmapped drive).
The file cannot be found.
specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission.
1
Sets the date and time the file was created.
The file for which to set the creation date and time information.
A containing the value to set for the creation date and time of . This value is expressed in local time.
The specified path was not found.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
An I/O error occurred while performing the operation.
specifies a value outside the range of dates, times, or both permitted for this operation.
The caller does not have the required permission.
is in an invalid format.
1
Sets the date and time, in coordinated universal time (UTC), that the file was created.
The file for which to set the creation date and time information.
A containing the value to set for the creation date and time of . This value is expressed in UTC time.
The specified path was not found.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
An I/O error occurred while performing the operation.
specifies a value outside the range of dates, times, or both permitted for this operation.
The caller does not have the required permission.
is in an invalid format.
2
Sets the date and time the specified file was last accessed.
The file for which to set the access date and time information.
A containing the value to set for the last access date and time of . This value is expressed in local time.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path was not found.
The caller does not have the required permission.
is in an invalid format.
specifies a value outside the range of dates or times permitted for this operation.
1
Sets the date and time, in coordinated universal time (UTC), that the specified file was last accessed.
The file for which to set the access date and time information.
A containing the value to set for the last access date and time of . This value is expressed in UTC time.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path was not found.
The caller does not have the required permission.
is in an invalid format.
specifies a value outside the range of dates or times permitted for this operation.
1
Sets the date and time that the specified file was last written to.
The file for which to set the date and time information.
A containing the value to set for the last write date and time of . This value is expressed in local time.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path was not found.
The caller does not have the required permission.
is in an invalid format.
specifies a value outside the range of dates or times permitted for this operation.
1
Sets the date and time, in coordinated universal time (UTC), that the specified file was last written to.
The file for which to set the date and time information.
A containing the value to set for the last write date and time of . This value is expressed in UTC time.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path was not found.
The caller does not have the required permission.
is in an invalid format.
specifies a value outside the range of dates or times permitted for this operation.
2
Creates a new file, writes the specified byte array to the file, and then closes the file. If the target file already exists, it is overwritten.
The file to write to.
The bytes to write to the file.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null or the byte array is empty.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid (for example, it is on an unmapped drive).
An I/O error occurred while opening the file.
specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission.
is in an invalid format.
The caller does not have the required permission.
1
Creates a new file, writes a collection of strings to the file, and then closes the file.
The file to write to.
The lines to write to the file.
is a zero-length string, contains only white space, or contains one or more invalid characters defined by the method.
Eitheror is null.
is invalid (for example, it is on an unmapped drive).
An I/O error occurred while opening the file.
exceeds the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
is in an invalid format.
The caller does not have the required permission.
specifies a file that is read-only.-or-This operation is not supported on the current platform.-or- is a directory.-or-The caller does not have the required permission.
Creates a new file by using the specified encoding, writes a collection of strings to the file, and then closes the file.
The file to write to.
The lines to write to the file.
The character encoding to use.
is a zero-length string, contains only white space, or contains one or more invalid characters defined by the method.
Either,, or is null.
is invalid (for example, it is on an unmapped drive).
An I/O error occurred while opening the file.
exceeds the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
is in an invalid format.
The caller does not have the required permission.
specifies a file that is read-only.-or-This operation is not supported on the current platform.-or- is a directory.-or-The caller does not have the required permission.
Creates a new file, writes the specified string to the file, and then closes the file. If the target file already exists, it is overwritten.
The file to write to.
The string to write to the file.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null or is empty.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid (for example, it is on an unmapped drive).
An I/O error occurred while opening the file.
specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission.
is in an invalid format.
The caller does not have the required permission.
1
Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. If the target file already exists, it is overwritten.
The file to write to.
The string to write to the file.
The encoding to apply to the string.
is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .
is null or is empty.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid (for example, it is on an unmapped drive).
An I/O error occurred while opening the file.
specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission.
is in an invalid format.
The caller does not have the required permission.
1
Provides properties and instance methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of objects. This class cannot be inherited.To browse the .NET Framework source code for this type, see the Reference Source.
1
Initializes a new instance of the class, which acts as a wrapper for a file path.
The fully qualified name of the new file, or the relative file name. Do not end the path with the directory separator character.
is null.
The caller does not have the required permission.
The file name is empty, contains only white spaces, or contains invalid characters.
Access to is denied.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
contains a colon (:) in the middle of the string.
Creates a that appends text to the file represented by this instance of the .
A new StreamWriter.
1
Copies an existing file to a new file, disallowing the overwriting of an existing file.
A new file with a fully qualified path.
The name of the new file to copy to.
is empty, contains only white spaces, or contains invalid characters.
An error occurs, or the destination file already exists.
The caller does not have the required permission.
is null.
A directory path is passed in, or the file is being moved to a different drive.
The directory specified in does not exist.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
contains a colon (:) within the string but does not specify the volume.
1
Copies an existing file to a new file, allowing the overwriting of an existing file.
A new file, or an overwrite of an existing file if is true. If the file exists and is false, an is thrown.
The name of the new file to copy to.
true to allow an existing file to be overwritten; otherwise, false.
is empty, contains only white spaces, or contains invalid characters.
An error occurs, or the destination file already exists and is false.
The caller does not have the required permission.
is null.
The directory specified in does not exist.
A directory path is passed in, or the file is being moved to a different drive.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
contains a colon (:) in the middle of the string.
1
Creates a file.
A new file.
1
Creates a that writes a new text file.
A new StreamWriter.
The file name is a directory.
The disk is read-only.
The caller does not have the required permission.
1
Permanently deletes a file.
The target file is open or memory-mapped on a computer running Microsoft Windows NT.-or-There is an open handle on the file, and the operating system is Windows XP or earlier. This open handle can result from enumerating directories and files. For more information, see How to: Enumerate Directories and Files.
The caller does not have the required permission.
The path is a directory.
1
Gets an instance of the parent directory.
A object representing the parent directory of this file.
The specified path is invalid, such as being on an unmapped drive.
The caller does not have the required permission.
1
Gets a string representing the directory's full path.
A string representing the directory's full path.
null was passed in for the directory name.
The fully qualified path is 260 or more characters.
The caller does not have the required permission.
1
Gets a value indicating whether a file exists.
true if the file exists; false if the file does not exist or if the file is a directory.
1
Gets or sets a value that determines if the current file is read only.
true if the current file is read only; otherwise, false.
The file described by the current object could not be found.
An I/O error occurred while opening the file.
This operation is not supported on the current platform.-or- The caller does not have the required permission.
The user does not have write permission, but attempted to set this property to false.
1
Gets the size, in bytes, of the current file.
The size of the current file in bytes.
cannot update the state of the file or directory.
The file does not exist.-or- The Length property is called for a directory.
1
Moves a specified file to a new location, providing the option to specify a new file name.
The path to move the file to, which can specify a different file name.
An I/O error occurs, such as the destination file already exists or the destination device is not ready.
is null.
is empty, contains only white spaces, or contains invalid characters.
The caller does not have the required permission.
is read-only or is a directory.
The file is not found.
The specified path is invalid, such as being on an unmapped drive.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
contains a colon (:) in the middle of the string.
1
Gets the name of the file.
The name of the file.
1
Opens a file in the specified mode.
A file opened in the specified mode, with read/write access and unshared.
A constant specifying the mode (for example, Open or Append) in which to open the file.
The file is not found.
The file is read-only or is a directory.
The specified path is invalid, such as being on an unmapped drive.
The file is already open.
2
Opens a file in the specified mode with read, write, or read/write access.
A object opened in the specified mode and access, and unshared.
A constant specifying the mode (for example, Open or Append) in which to open the file.
A constant specifying whether to open the file with Read, Write, or ReadWrite file access.
The caller does not have the required permission.
The file is not found.
is read-only or is a directory.
The specified path is invalid, such as being on an unmapped drive.
The file is already open.
2
Opens a file in the specified mode with read, write, or read/write access and the specified sharing option.
A object opened with the specified mode, access, and sharing options.
A constant specifying the mode (for example, Open or Append) in which to open the file.
A constant specifying whether to open the file with Read, Write, or ReadWrite file access.
A constant specifying the type of access other FileStream objects have to this file.
The caller does not have the required permission.
The file is not found.
is read-only or is a directory.
The specified path is invalid, such as being on an unmapped drive.
The file is already open.
2
Creates a read-only .
A new read-only object.
is read-only or is a directory.
The specified path is invalid, such as being on an unmapped drive.
The file is already open.
2
Creates a with UTF8 encoding that reads from an existing text file.
A new StreamReader with UTF8 encoding.
The caller does not have the required permission.
The file is not found.
is read-only or is a directory.
The specified path is invalid, such as being on an unmapped drive.
2
Creates a write-only .
A write-only unshared object for a new or existing file.
The path specified when creating an instance of the object is read-only or is a directory.
The path specified when creating an instance of the object is invalid, such as being on an unmapped drive.
2
Returns the path as a string.
A string representing the path.
1
Represents advanced options for creating a object.
1
Indicates that a file can be used for asynchronous reading and writing.
Indicates that a file is automatically deleted when it is no longer in use.
Indicates that a file is encrypted and can be decrypted only by using the same user account used for encryption.
Indicates that no additional options should be used when creating a object.
Indicates that the file is accessed randomly. The system can use this as a hint to optimize file caching.
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.
Indicates that the system should write through any intermediate cache and go directly to disk.
Provides a 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.
1
Initializes a new instance of the class for the specified file handle, with the specified read/write permission.
A file handle for the file that the current FileStream object will encapsulate.
A constant that sets the and properties of the FileStream object.
is not a field of .
The caller does not have the required permission.
An I/O error, such as a disk error, occurred.-or-The stream has been closed.
The requested is not permitted by the operating system for the specified file handle, such as when is Write or ReadWrite and the file handle is set for read-only access.
Initializes a new instance of the class for the specified file handle, with the specified read/write permission, and buffer size.
A file handle for the file that the current FileStream object will encapsulate.
A constant that sets the and properties of the FileStream object.
A positive value greater than 0 indicating the buffer size. The default buffer size is 4096.
The parameter is an invalid handle.-or-The parameter is a synchronous handle and it was used asynchronously.
The parameter is negative.
An I/O error, such as a disk error, occurred.-or-The stream has been closed.
The caller does not have the required permission.
The requested is not permitted by the operating system for the specified file handle, such as when is Write or ReadWrite and the file handle is set for read-only access.
Initializes a new instance of the class for the specified file handle, with the specified read/write permission, buffer size, and synchronous or asynchronous state.
A file handle for the file that this FileStream object will encapsulate.
A constant that sets the and properties of the FileStream object.
A positive value greater than 0 indicating the buffer size. The default buffer size is 4096.
true if the handle was opened asynchronously (that is, in overlapped I/O mode); otherwise, false.
The parameter is an invalid handle.-or-The parameter is a synchronous handle and it was used asynchronously.
The parameter is negative.
An I/O error, such as a disk error, occurred.-or-The stream has been closed.
The caller does not have the required permission.
The requested is not permitted by the operating system for the specified file handle, such as when is Write or ReadWrite and the file handle is set for read-only access.
Initializes a new instance of the class with the specified path and creation mode.
A relative or absolute path for the file that the current FileStream object will encapsulate.
A constant that determines how to open or create the file.
is an empty string (""), contains only white space, or contains one or more invalid characters. -or- refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in an NTFS environment.
refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in a non-NTFS environment.
is null.
The caller does not have the required permission.
The file cannot be found, such as when is FileMode.Truncate or FileMode.Open, and the file specified by does not exist. The file must already exist in these modes.
An I/O error, such as specifying FileMode.CreateNew when the file specified by already exists, occurred.-or-The stream has been closed.
The specified path is invalid, such as being on an unmapped drive.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
contains an invalid value.
Initializes a new instance of the class with the specified path, creation mode, and read/write permission.
A relative or absolute path for the file that the current FileStream object will encapsulate.
A constant that determines how to open or create the file.
A constant that determines how the file can be accessed by the FileStream object. This also determines the values returned by the and properties of the FileStream object. is true if specifies a disk file.
is null.
is an empty string (""), contains only white space, or contains one or more invalid characters. -or- refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in an NTFS environment.
refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in a non-NTFS environment.
The file cannot be found, such as when is FileMode.Truncate or FileMode.Open, and the file specified by does not exist. The file must already exist in these modes.
An I/O error, such as specifying FileMode.CreateNew when the file specified by already exists, occurred. -or-The stream has been closed.
The caller does not have the required permission.
The specified path is invalid, such as being on an unmapped drive.
The requested is not permitted by the operating system for the specified , such as when is Write or ReadWrite and the file or directory is set for read-only access.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
contains an invalid value.
Initializes a new instance of the class with the specified path, creation mode, read/write permission, and sharing permission.
A relative or absolute path for the file that the current FileStream object will encapsulate.
A constant that determines how to open or create the file.
A constant that determines how the file can be accessed by the FileStream object. This also determines the values returned by the and properties of the FileStream object. is true if specifies a disk file.
A constant that determines how the file will be shared by processes.
is null.
is an empty string (""), contains only white space, or contains one or more invalid characters. -or- refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in an NTFS environment.
refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in a non-NTFS environment.
The file cannot be found, such as when is FileMode.Truncate or FileMode.Open, and the file specified by does not exist. The file must already exist in these modes.
An I/O error, such as specifying FileMode.CreateNew when the file specified by already exists, occurred. -or-The system is running Windows 98 or Windows 98 Second Edition and is set to FileShare.Delete.-or-The stream has been closed.
The caller does not have the required permission.
The specified path is invalid, such as being on an unmapped drive.
The requested is not permitted by the operating system for the specified , such as when is Write or ReadWrite and the file or directory is set for read-only access.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
contains an invalid value.
Initializes a new instance of the class with the specified path, creation mode, read/write and sharing permission, and buffer size.
A relative or absolute path for the file that the current FileStream object will encapsulate.
A constant that determines how to open or create the file.
A constant that determines how the file can be accessed by the FileStream object. This also determines the values returned by the and properties of the FileStream object. is true if specifies a disk file.
A constant that determines how the file will be shared by processes.
A positive value greater than 0 indicating the buffer size. The default buffer size is 4096.
is null.
is an empty string (""), contains only white space, or contains one or more invalid characters. -or- refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in an NTFS environment.
refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in a non-NTFS environment.
is negative or zero.-or- , , or contain an invalid value.
The file cannot be found, such as when is FileMode.Truncate or FileMode.Open, and the file specified by does not exist. The file must already exist in these modes.
An I/O error, such as specifying FileMode.CreateNew when the file specified by already exists, occurred. -or-The system is running Windows 98 or Windows 98 Second Edition and is set to FileShare.Delete.-or-The stream has been closed.
The caller does not have the required permission.
The specified path is invalid, such as being on an unmapped drive.
The requested is not permitted by the operating system for the specified , such as when is Write or ReadWrite and the file or directory is set for read-only access.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
Initializes a new instance of the class with the specified path, creation mode, read/write and sharing permission, buffer size, and synchronous or asynchronous state.
A relative or absolute path for the file that the current FileStream object will encapsulate.
A constant that determines how to open or create the file.
A constant that determines how the file can be accessed by the FileStream object. This also determines the values returned by the and properties of the FileStream object. is true if specifies a disk file.
A constant that determines how the file will be shared by processes.
A positive value greater than 0 indicating the buffer size. The default buffer size is 4096..
Specifies whether to use asynchronous I/O or synchronous I/O. However, note that the underlying operating system might not support asynchronous I/O, so when specifying true, the handle might be opened synchronously depending on the platform. When opened asynchronously, the and methods perform better on large reads or writes, but they might be much slower for small reads or writes. If the application is designed to take advantage of asynchronous I/O, set the parameter to true. Using asynchronous I/O correctly can speed up applications by as much as a factor of 10, but using it without redesigning the application for asynchronous I/O can decrease performance by as much as a factor of 10.
is null.
is an empty string (""), contains only white space, or contains one or more invalid characters. -or- refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in an NTFS environment.
refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in a non-NTFS environment.
is negative or zero.-or- , , or contain an invalid value.
The file cannot be found, such as when is FileMode.Truncate or FileMode.Open, and the file specified by does not exist. The file must already exist in these modes.
An I/O error, such as specifying FileMode.CreateNew when the file specified by already exists, occurred.-or- The system is running Windows 98 or Windows 98 Second Edition and is set to FileShare.Delete.-or-The stream has been closed.
The caller does not have the required permission.
The specified path is invalid, such as being on an unmapped drive.
The requested is not permitted by the operating system for the specified , such as when is Write or ReadWrite and the file or directory is set for read-only access.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
Initializes a new instance of the class with the specified path, creation mode, read/write and sharing permission, the access other FileStreams can have to the same file, the buffer size, and additional file options.
A relative or absolute path for the file that the current FileStream object will encapsulate.
A constant that determines how to open or create the file.
A constant that determines how the file can be accessed by the FileStream object. This also determines the values returned by the and properties of the FileStream object. is true if specifies a disk file.
A constant that determines how the file will be shared by processes.
A positive value greater than 0 indicating the buffer size. The default buffer size is 4096.
A value that specifies additional file options.
is null.
is an empty string (""), contains only white space, or contains one or more invalid characters. -or- refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in an NTFS environment.
refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in a non-NTFS environment.
is negative or zero.-or- , , or contain an invalid value.
The file cannot be found, such as when is FileMode.Truncate or FileMode.Open, and the file specified by does not exist. The file must already exist in these modes.
An I/O error, such as specifying FileMode.CreateNew when the file specified by already exists, occurred.-or-The stream has been closed.
The caller does not have the required permission.
The specified path is invalid, such as being on an unmapped drive.
The requested is not permitted by the operating system for the specified , such as when is Write or ReadWrite and the file or directory is set for read-only access. -or- is specified for , but file encryption is not supported on the current platform.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
Gets a value indicating whether the current stream supports reading.
true if the stream supports reading; false if the stream is closed or was opened with write-only access.
1
Gets a value indicating whether the current stream supports seeking.
true if the stream supports seeking; false if the stream is closed or if the FileStream was constructed from an operating-system handle such as a pipe or output to the console.
2
Gets a value indicating whether the current stream supports writing.
true if the stream supports writing; false if the stream is closed or was opened with read-only access.
1
Releases the unmanaged resources used by the and optionally releases the managed resources.
true to release both managed and unmanaged resources; false to release only unmanaged resources.
Ensures that resources are freed and other cleanup operations are performed when the garbage collector reclaims the FileStream.
Clears buffers for this stream and causes any buffered data to be written to the file.
An I/O error occurred.
The stream is closed.
1
Clears buffers for this stream and causes any buffered data to be written to the file, and also clears all intermediate file buffers.
true to flush all intermediate file buffers; otherwise, false.
Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying device, and monitors cancellation requests.
A task that represents the asynchronous flush operation.
The token to monitor for cancellation requests.
The stream has been disposed.
Gets a value indicating whether the FileStream was opened asynchronously or synchronously.
true if the FileStream was opened asynchronously; otherwise, false.
2
Gets the length in bytes of the stream.
A long value representing the length of the stream in bytes.
for this stream is false.
An I/O error, such as the file being closed, occurred.
1
Gets the name of the FileStream that was passed to the constructor.
A string that is the name of the FileStream.
1
Gets or sets the current position of this stream.
The current position of this stream.
The stream does not support seeking.
An I/O error occurred. - or -The position was set to a very large value beyond the end of the stream in Windows 98 or earlier.
Attempted to set the position to a negative value.
Attempted seeking past the end of a stream that does not support this.
1
Reads a block of bytes from the stream and writes the data in a given buffer.
The total number of bytes read into the buffer. This might be less than the number of bytes requested if that number of bytes are not currently available, or zero if the end of the stream is reached.
When this method returns, contains the specified byte array with the values between and ( + - 1 replaced by the bytes read from the current source.
The byte offset in at which the read bytes will be placed.
The maximum number of bytes to read.
is null.
or is negative.
The stream does not support reading.
An I/O error occurred.
and describe an invalid range in .
Methods were called after the stream was closed.
1
Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.
A task that represents the asynchronous read operation. The value of the parameter contains the total number of bytes read into the buffer. The result value can be less than the number of bytes requested if the number of bytes currently available is less than the requested number, or it can be 0 (zero) if the end of the stream has been reached.
The buffer to write the data into.
The byte offset in at which to begin writing data from the stream.
The maximum number of bytes to read.
The token to monitor for cancellation requests.
is null.
or is negative.
The sum of and is larger than the buffer length.
The stream does not support reading.
The stream has been disposed.
The stream is currently in use by a previous read operation.
Reads a byte from the file and advances the read position one byte.
The byte, cast to an , or -1 if the end of the stream has been reached.
The current stream does not support reading.
The current stream is closed.
1
Gets a object that represents the operating system file handle for the file that the current object encapsulates.
An object that represents the operating system file handle for the file that the current object encapsulates.
1
Sets the current position of this stream to the given value.
The new position in the stream.
The point relative to from which to begin seeking.
Specifies the beginning, the end, or the current position as a reference point for , using a value of type .
An I/O error occurred.
The stream does not support seeking, such as if the FileStream is constructed from a pipe or console output.
Seeking is attempted before the beginning of the stream.
Methods were called after the stream was closed.
1
Sets the length of this stream to the given value.
The new length of the stream.
An I/O error has occurred.
The stream does not support both writing and seeking.
Attempted to set the parameter to less than 0.
2
Writes a block of bytes to the file stream.
The buffer containing data to write to the stream.
The zero-based byte offset in from which to begin copying bytes to the stream.
The maximum number of bytes to write.
is null.
and describe an invalid range in .
or is negative.
An I/O error occurred. - or -Another thread may have caused an unexpected change in the position of the operating system's file handle.
The stream is closed.
The current stream instance does not support writing.
1
Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.
A task that represents the asynchronous write operation.
The buffer to write data from.
The zero-based byte offset in from which to begin copying bytes to the stream.
The maximum number of bytes to write.
The token to monitor for cancellation requests.
is null.
or is negative.
The sum of and is larger than the buffer length.
The stream does not support writing.
The stream has been disposed.
The stream is currently in use by a previous write operation.
Writes a byte to the current position in the file stream.
A byte to write to the stream.
The stream is closed.
The stream does not support writing.
1
Provides the base class for both and objects.
2
Initializes a new instance of the class.
Gets or sets the attributes for the current file or directory.
of the current .
The specified file does not exist.
The specified path is invalid; for example, it is on an unmapped drive.
The caller does not have the required permission.
The caller attempts to set an invalid file attribute. -or-The user attempts to set an attribute value but does not have write permission.
cannot initialize the data.
1
Gets or sets the creation time of the current file or directory.
The creation date and time of the current object.
cannot initialize the data.
The specified path is invalid; for example, it is on an unmapped drive.
The current operating system is not Windows NT or later.
The caller attempts to set an invalid creation time.
1
Gets or sets the creation time, in coordinated universal time (UTC), of the current file or directory.
The creation date and time in UTC format of the current object.
cannot initialize the data.
The specified path is invalid; for example, it is on an unmapped drive.
The current operating system is not Windows NT or later.
The caller attempts to set an invalid access time.
1
Deletes a file or directory.
The specified path is invalid; for example, it is on an unmapped drive.
There is an open handle on the file or directory, and the operating system is Windows XP or earlier. This open handle can result from enumerating directories and files. For more information, see How to: Enumerate Directories and Files.
2
Gets a value indicating whether the file or directory exists.
true if the file or directory exists; otherwise, false.
1
Gets the string representing the extension part of the file.
A string containing the extension.
1
Gets the full path of the directory or file.
A string containing the full path.
The fully qualified path and file name is 260 or more characters.
The caller does not have the required permission.
1
Represents the fully qualified path of the directory or file.
The fully qualified path is 260 or more characters.
Gets or sets the time the current file or directory was last accessed.
The time that the current file or directory was last accessed.
cannot initialize the data.
The current operating system is not Windows NT or later.
The caller attempts to set an invalid access time
1
Gets or sets the time, in coordinated universal time (UTC), that the current file or directory was last accessed.
The UTC time that the current file or directory was last accessed.
cannot initialize the data.
The current operating system is not Windows NT or later.
The caller attempts to set an invalid access time.
1
Gets or sets the time when the current file or directory was last written to.
The time the current file was last written.
cannot initialize the data.
The current operating system is not Windows NT or later.
The caller attempts to set an invalid write time.
1
Gets or sets the time, in coordinated universal time (UTC), when the current file or directory was last written to.
The UTC time when the current file was last written to.
cannot initialize the data.
The current operating system is not Windows NT or later.
The caller attempts to set an invalid write time.
1
For files, gets the name of the file. For directories, gets the name of the last directory in the hierarchy if a hierarchy exists. Otherwise, the Name property gets the name of the directory.
A string that is the name of the parent directory, the name of the last directory in the hierarchy, or the name of a file, including the file name extension.
1
The path originally specified by the user, whether relative or absolute.
Refreshes the state of the object.
A device such as a disk drive is not ready.
1
Specifies whether to search the current directory, or the current directory and all subdirectories.
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.
Includes only the current directory in a search operation.