mscorlib(4.0.0.0) API with additions
|
Provides static methods for the creation, copying, deletion, moving, and opening of a single file, and aids in the creation of T:System.IO.FileStream objects.To browse the .NET Framework source code for this type, see the Reference Source. More...
Static Public Member Functions | |
static StreamReader | OpenText (string path) |
Opens an existing UTF-8 encoded text file for reading. More... | |
static StreamWriter | CreateText (string path) |
Creates or opens a file for writing UTF-8 encoded text. More... | |
static StreamWriter | AppendText (string path) |
Creates a T:System.IO.StreamWriter that appends UTF-8 encoded text to an existing file, or to a new file if the specified file does not exist. More... | |
static void | Copy (string sourceFileName, string destFileName) |
Copies an existing file to a new file. Overwriting a file of the same name is not allowed. More... | |
static void | Copy (string sourceFileName, string destFileName, bool overwrite) |
Copies an existing file to a new file. Overwriting a file of the same name is allowed. More... | |
static FileStream | Create (string path) |
Creates or overwrites a file in the specified path. More... | |
static FileStream | Create (string path, int bufferSize) |
Creates or overwrites the specified file. More... | |
static FileStream | Create (string path, int bufferSize, FileOptions options) |
Creates or overwrites the specified file, specifying a buffer size and a T:System.IO.FileOptions value that describes how to create or overwrite the file. More... | |
static FileStream | Create (string path, int bufferSize, FileOptions options, FileSecurity fileSecurity) |
Creates or overwrites the specified file with the specified buffer size, file options, and file security. More... | |
static void | Delete (string path) |
Deletes the specified file. More... | |
static void | Decrypt (string path) |
Decrypts a file that was encrypted by the current account using the M:System.IO.File.Encrypt(System.String) method. More... | |
static void | Encrypt (string path) |
Encrypts a file so that only the account used to encrypt the file can decrypt it. More... | |
static bool | Exists (string path) |
Determines whether the specified file exists. More... | |
static FileStream | Open (string path, FileMode mode) |
Opens a T:System.IO.FileStream on the specified path with read/write access. More... | |
static FileStream | Open (string path, FileMode mode, FileAccess access) |
Opens a T:System.IO.FileStream on the specified path, with the specified mode and access. More... | |
static FileStream | Open (string path, FileMode mode, FileAccess access, FileShare share) |
Opens a T:System.IO.FileStream on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option. More... | |
static void | SetCreationTime (string path, DateTime creationTime) |
Sets the date and time the file was created. More... | |
static unsafe void | SetCreationTimeUtc (string path, DateTime creationTimeUtc) |
Sets the date and time, in coordinated universal time (UTC), that the file was created. More... | |
static DateTime | GetCreationTime (string path) |
Returns the creation date and time of the specified file or directory. More... | |
static DateTime | GetCreationTimeUtc (string path) |
Returns the creation date and time, in coordinated universal time (UTC), of the specified file or directory. More... | |
static void | SetLastAccessTime (string path, DateTime lastAccessTime) |
Sets the date and time the specified file was last accessed. More... | |
static unsafe void | SetLastAccessTimeUtc (string path, DateTime lastAccessTimeUtc) |
Sets the date and time, in coordinated universal time (UTC), that the specified file was last accessed. More... | |
static DateTime | GetLastAccessTime (string path) |
Returns the date and time the specified file or directory was last accessed. More... | |
static DateTime | GetLastAccessTimeUtc (string path) |
Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last accessed. More... | |
static void | SetLastWriteTime (string path, DateTime lastWriteTime) |
Sets the date and time that the specified file was last written to. More... | |
static unsafe void | SetLastWriteTimeUtc (string path, DateTime lastWriteTimeUtc) |
Sets the date and time, in coordinated universal time (UTC), that the specified file was last written to. More... | |
static DateTime | GetLastWriteTime (string path) |
Returns the date and time the specified file or directory was last written to. More... | |
static DateTime | GetLastWriteTimeUtc (string path) |
Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last written to. More... | |
static FileAttributes | GetAttributes (string path) |
Gets the T:System.IO.FileAttributes of the file on the path. More... | |
static void | SetAttributes (string path, FileAttributes fileAttributes) |
Sets the specified T:System.IO.FileAttributes of the file on the specified path. More... | |
static FileSecurity | GetAccessControl (string path) |
Gets a T:System.Security.AccessControl.FileSecurity object that encapsulates the access control list (ACL) entries for a specified file. More... | |
static FileSecurity | GetAccessControl (string path, AccessControlSections includeSections) |
Gets a T:System.Security.AccessControl.FileSecurity object that encapsulates the specified type of access control list (ACL) entries for a particular file. More... | |
static void | SetAccessControl (string path, FileSecurity fileSecurity) |
Applies access control list (ACL) entries described by a T:System.Security.AccessControl.FileSecurity object to the specified file. More... | |
static FileStream | OpenRead (string path) |
Opens an existing file for reading. More... | |
static FileStream | OpenWrite (string path) |
Opens an existing file or creates a new file for writing. More... | |
static string | ReadAllText (string path) |
Opens a text file, reads all lines of the file, and then closes the file. More... | |
static string | ReadAllText (string path, Encoding encoding) |
Opens a file, reads all lines of the file with the specified encoding, and then closes the file. More... | |
static void | WriteAllText (string path, string contents) |
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. More... | |
static void | WriteAllText (string path, string contents, Encoding encoding) |
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. More... | |
static byte [] | ReadAllBytes (string path) |
Opens a binary file, reads the contents of the file into a byte array, and then closes the file. More... | |
static void | WriteAllBytes (string path, byte[] bytes) |
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. More... | |
static string [] | ReadAllLines (string path) |
Opens a text file, reads all lines of the file, and then closes the file. More... | |
static string [] | ReadAllLines (string path, Encoding encoding) |
Opens a file, reads all lines of the file with the specified encoding, and then closes the file. More... | |
static IEnumerable< string > | ReadLines (string path) |
Reads the lines of a file. More... | |
static IEnumerable< string > | ReadLines (string path, Encoding encoding) |
Read the lines of a file that has a specified encoding. More... | |
static void | WriteAllLines (string path, string[] contents) |
Creates a new file, write the specified string array to the file, and then closes the file. More... | |
static void | WriteAllLines (string path, string[] contents, Encoding encoding) |
Creates a new file, writes the specified string array to the file by using the specified encoding, and then closes the file. More... | |
static void | WriteAllLines (string path, IEnumerable< string > contents) |
Creates a new file, writes a collection of strings to the file, and then closes the file. More... | |
static void | WriteAllLines (string path, IEnumerable< string > contents, Encoding encoding) |
Creates a new file by using the specified encoding, writes a collection of strings to the file, and then closes the file. More... | |
static void | AppendAllText (string path, string contents) |
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. More... | |
static void | AppendAllText (string path, string contents, Encoding encoding) |
Appends the specified string to the file, creating the file if it does not already exist. More... | |
static void | AppendAllLines (string path, IEnumerable< string > contents) |
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. More... | |
static void | AppendAllLines (string path, IEnumerable< string > contents, Encoding encoding) |
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. More... | |
static void | Move (string sourceFileName, string destFileName) |
Moves a specified file to a new location, providing the option to specify a new file name. More... | |
static void | Replace (string sourceFileName, string destinationFileName, string destinationBackupFileName) |
Replaces the contents of a specified file with the contents of another file, deleting the original file, and creating a backup of the replaced file. More... | |
static void | Replace (string sourceFileName, string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors) |
Replaces the contents of a specified file with the contents of another file, deleting the original file, and creating a backup of the replaced file and optionally ignores merge errors. More... | |
Provides static methods for the creation, copying, deletion, moving, and opening of a single file, and aids in the creation of T:System.IO.FileStream objects.To browse the .NET Framework source code for this type, see the Reference Source.
|
static |
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.
path | The file to append the lines to. The file is created if it doesn't already exist. |
contents | The lines to append to the file. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one more invalid characters defined by the M:System.IO.Path.GetInvalidPathChars method. |
T:System.ArgumentNullException | Either path or contents is null . |
T:System.IO.DirectoryNotFoundException | path is invalid (for example, the directory doesn’t exist or it is on an unmapped drive). |
T:System.IO.FileNotFoundException | The file specified by path was not found. |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.IO.PathTooLongException | path 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. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.Security.SecurityException | The caller does not have permission to write to the file. |
T:System.UnauthorizedAccessException | path specifies a file that is read-only.-or-This operation is not supported on the current platform.-or- path is a directory. |
|
static |
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.
path | The file to append the lines to. The file is created if it doesn't already exist. |
contents | The lines to append to the file. |
encoding | The character encoding to use. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one more invalid characters defined by the M:System.IO.Path.GetInvalidPathChars method. |
T:System.ArgumentNullException | Either path , contents , or encoding is null . |
T:System.IO.DirectoryNotFoundException | path is invalid (for example, the directory doesn’t exist or it is on an unmapped drive). |
T:System.IO.FileNotFoundException | The file specified by path was not found. |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.IO.PathTooLongException | path 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. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.Security.SecurityException | The caller does not have the required permission. |
T:System.UnauthorizedAccessException | path specifies a file that is read-only.-or-This operation is not supported on the current platform.-or- path is a directory.-or-The caller does not have the required permission. |
|
static |
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.
path | The file to append the specified string to. |
contents | The string to append to the file. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid (for example, the directory doesn’t exist or it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.UnauthorizedAccessException | path specified a file that is read-only.-or- This operation is not supported on the current platform.-or- path specified a directory.-or- The caller does not have the required permission. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.Security.SecurityException | The caller does not have the required permission. |
|
static |
Appends the specified string to the file, creating the file if it does not already exist.
path | The file to append the specified string to. |
contents | The string to append to the file. |
encoding | The character encoding to use. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid (for example, the directory doesn’t exist or it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.UnauthorizedAccessException | path specified a file that is read-only.-or- This operation is not supported on the current platform.-or- path specified a directory.-or- The caller does not have the required permission. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.Security.SecurityException | The caller does not have the required permission. |
|
static |
Creates a T:System.IO.StreamWriter that appends UTF-8 encoded text to an existing file, or to a new file if the specified file does not exist.
path | The path to the file to append to. |
T:System.UnauthorizedAccessException | The caller does not have the required permission. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid (for example, the directory doesn’t exist or it is on an unmapped drive). |
T:System.NotSupportedException | path is in an invalid format. |
|
static |
Copies an existing file to a new file. Overwriting a file of the same name is not allowed.
sourceFileName | The file to copy. |
destFileName | The name of the destination file. This cannot be a directory or an existing file. |
T:System.UnauthorizedAccessException | The caller does not have the required permission. |
T:System.ArgumentException | sourceFileName or destFileName is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars.-or- sourceFileName or destFileName specifies a directory. |
T:System.ArgumentNullException | sourceFileName or destFileName is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The path specified in sourceFileName or destFileName is invalid (for example, it is on an unmapped drive). |
T:System.IO.FileNotFoundException | sourceFileName was not found. |
T:System.IO.IOException | destFileName exists.-or- An I/O error has occurred. |
T:System.NotSupportedException | sourceFileName or destFileName is in an invalid format. |
|
static |
Copies an existing file to a new file. Overwriting a file of the same name is allowed.
sourceFileName | The file to copy. |
destFileName | The name of the destination file. This cannot be a directory. |
overwrite | true if the destination file can be overwritten; otherwise, false . |
T:System.UnauthorizedAccessException | The caller does not have the required permission. -or- destFileName is read-only. |
T:System.ArgumentException | sourceFileName or destFileName is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars.-or- sourceFileName or destFileName specifies a directory. |
T:System.ArgumentNullException | sourceFileName or destFileName is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The path specified in sourceFileName or destFileName is invalid (for example, it is on an unmapped drive). |
T:System.IO.FileNotFoundException | sourceFileName was not found. |
T:System.IO.IOException | destFileName exists and overwrite is false .-or- An I/O error has occurred. |
T:System.NotSupportedException | sourceFileName or destFileName is in an invalid format. |
|
static |
Creates or overwrites a file in the specified path.
path | The path and name of the file to create. |
T:System.UnauthorizedAccessException | The caller does not have the required permission.-or- path specified a file that is read-only. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid (for example, it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while creating the file. |
T:System.NotSupportedException | path is in an invalid format. |
|
static |
Creates or overwrites the specified file.
path | The name of the file. |
bufferSize | The number of bytes buffered for reads and writes to the file. |
T:System.UnauthorizedAccessException | The caller does not have the required permission.-or- path specified a file that is read-only. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid (for example, it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while creating the file. |
T:System.NotSupportedException | path is in an invalid format. |
|
static |
Creates or overwrites the specified file, specifying a buffer size and a T:System.IO.FileOptions value that describes how to create or overwrite the file.
path | The name of the file. |
bufferSize | The number of bytes buffered for reads and writes to the file. |
options | One of the T:System.IO.FileOptions values that describes how to create or overwrite the file. |
T:System.UnauthorizedAccessException | The caller does not have the required permission.-or- path specified a file that is read-only. -or- F:System.IO.FileOptions.Encrypted is specified for options and file encryption is not supported on the current platform. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid (for example, it is on an unmapped drive. |
T:System.IO.IOException | An I/O error occurred while creating the file. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.UnauthorizedAccessException | The caller does not have the required permission.-or- path specified a file that is read-only. |
T:System.UnauthorizedAccessException | The caller does not have the required permission.-or- path specified a file that is read-only. |
|
static |
Creates or overwrites the specified file with the specified buffer size, file options, and file security.
path | The name of the file. |
bufferSize | The number of bytes buffered for reads and writes to the file. |
options | One of the T:System.IO.FileOptions values that describes how to create or overwrite the file. |
fileSecurity | One of the T:System.Security.AccessControl.FileSecurity values that determines the access control and audit security for the file. |
T:System.UnauthorizedAccessException | The caller does not have the required permission.-or- path specified a file that is read-only.-or- F:System.IO.FileOptions.Encrypted is specified for options and file encryption is not supported on the current platform. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid (for example, it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while creating the file. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.UnauthorizedAccessException | The caller does not have the required permission.-or- path specified a file that is read-only. |
T:System.UnauthorizedAccessException | The caller does not have the required permission.-or- path specified a file that is read-only. |
|
static |
Creates or opens a file for writing UTF-8 encoded text.
path | The file to be opened for writing. |
T:System.UnauthorizedAccessException | The caller does not have the required permission. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid (for example, it is on an unmapped drive). |
T:System.NotSupportedException | path is in an invalid format. |
|
static |
Decrypts a file that was encrypted by the current account using the M:System.IO.File.Encrypt(System.String) method.
path | A path that describes a file to decrypt. |
T:System.ArgumentException | The path parameter is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | The path parameter is null . |
T:System.IO.DriveNotFoundException | An invalid drive was specified. |
T:System.IO.FileNotFoundException | The file described by the path parameter could not be found. |
T:System.IO.IOException | An I/O error occurred while opening the file. For example, the encrypted file is already open. -or-This operation is not supported on the current platform. |
T:System.IO.PathTooLongException | 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. |
T:System.PlatformNotSupportedException | The current operating system is not Windows NT or later. |
T:System.NotSupportedException | The file system is not NTFS. |
T:System.UnauthorizedAccessException | The path parameter specified a file that is read-only.-or- This operation is not supported on the current platform.-or- The path parameter specified a directory.-or- The caller does not have the required permission. |
|
static |
Deletes the specified file.
path | The name of the file to be deleted. Wildcard characters are not supported. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.DirectoryNotFoundException | The specified path is invalid (for example, it is on an unmapped drive). |
T:System.IO.IOException | 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. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.IO.PathTooLongException | 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. |
T:System.UnauthorizedAccessException | The caller does not have the required permission.-or- The file is an executable file that is in use.-or- path is a directory.-or- path specified a read-only file. |
|
static |
Encrypts a file so that only the account used to encrypt the file can decrypt it.
path | A path that describes a file to encrypt. |
T:System.ArgumentException | The path parameter is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | The path parameter is null . |
T:System.IO.DriveNotFoundException | An invalid drive was specified. |
T:System.IO.FileNotFoundException | The file described by the path parameter could not be found. |
T:System.IO.IOException | An I/O error occurred while opening the file.-or-This operation is not supported on the current platform. |
T:System.IO.PathTooLongException | 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. |
T:System.PlatformNotSupportedException | The current operating system is not Windows NT or later. |
T:System.NotSupportedException | The file system is not NTFS. |
T:System.UnauthorizedAccessException | The path parameter specified a file that is read-only.-or- This operation is not supported on the current platform.-or- The path parameter specified a directory.-or- The caller does not have the required permission. |
|
static |
Determines whether the specified file exists.
path | The file to check. |
true
if the caller has the required permissions and path contains the name of an existing file; otherwise, false
. This method also returns false
if path 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 path .
|
static |
Gets a T:System.Security.AccessControl.FileSecurity object that encapsulates the access control list (ACL) entries for a specified file.
path | The path to a file containing a T:System.Security.AccessControl.FileSecurity object that describes the file's access control list (ACL) information. |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.Runtime.InteropServices.SEHException | The path parameter is null . |
T:System.SystemException | The file could not be found. |
T:System.UnauthorizedAccessException | The path parameter specified a file that is read-only.-or- This operation is not supported on the current platform.-or- The path parameter specified a directory.-or- The caller does not have the required permission. |
|
static |
Gets a T:System.Security.AccessControl.FileSecurity object that encapsulates the specified type of access control list (ACL) entries for a particular file.
path | The path to a file containing a T:System.Security.AccessControl.FileSecurity object that describes the file's access control list (ACL) information. |
includeSections | One of the T:System.Security.AccessControl.AccessControlSections values that specifies the type of access control list (ACL) information to receive. |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.Runtime.InteropServices.SEHException | The path parameter is null . |
T:System.SystemException | The file could not be found. |
T:System.UnauthorizedAccessException | The path parameter specified a file that is read-only.-or- This operation is not supported on the current platform.-or- The path parameter specified a directory.-or- The caller does not have the required permission. |
|
static |
Gets the T:System.IO.FileAttributes of the file on the path.
path | The path to the file. |
T:System.ArgumentException | path is empty, contains only white spaces, or contains invalid characters. |
T:System.IO.PathTooLongException | 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. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.IO.FileNotFoundException | path represents a file and is invalid, such as being on an unmapped drive, or the file cannot be found. |
T:System.IO.DirectoryNotFoundException | path represents a directory and is invalid, such as being on an unmapped drive, or the directory cannot be found. |
T:System.IO.IOException | This file is being used by another process. |
T:System.UnauthorizedAccessException | The caller does not have the required permission. |
|
static |
Returns the creation date and time of the specified file or directory.
path | The file or directory for which to obtain creation date and time information. |
T:System.UnauthorizedAccessException | The caller does not have the required permission. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.NotSupportedException | path is in an invalid format. |
|
static |
Returns the creation date and time, in coordinated universal time (UTC), of the specified file or directory.
path | The file or directory for which to obtain creation date and time information. |
T:System.UnauthorizedAccessException | The caller does not have the required permission. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.NotSupportedException | path is in an invalid format. |
|
static |
Returns the date and time the specified file or directory was last accessed.
path | The file or directory for which to obtain access date and time information. |
T:System.UnauthorizedAccessException | The caller does not have the required permission. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.NotSupportedException | path is in an invalid format. |
|
static |
Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last accessed.
path | The file or directory for which to obtain access date and time information. |
T:System.UnauthorizedAccessException | The caller does not have the required permission. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.NotSupportedException | path is in an invalid format. |
|
static |
Returns the date and time the specified file or directory was last written to.
path | The file or directory for which to obtain write date and time information. |
T:System.UnauthorizedAccessException | The caller does not have the required permission. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.NotSupportedException | path is in an invalid format. |
|
static |
Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last written to.
path | The file or directory for which to obtain write date and time information. |
T:System.UnauthorizedAccessException | The caller does not have the required permission. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.NotSupportedException | path is in an invalid format. |
|
static |
Moves a specified file to a new location, providing the option to specify a new file name.
sourceFileName | The name of the file to move. Can include a relative or absolute path. |
destFileName | The new path and name for the file. |
T:System.IO.IOException | The destination file already exists.-or- sourceFileName was not found. |
T:System.ArgumentNullException | sourceFileName or destFileName is null . |
T:System.ArgumentException | sourceFileName or destFileName is a zero-length string, contains only white space, or contains invalid characters as defined in F:System.IO.Path.InvalidPathChars. |
T:System.UnauthorizedAccessException | The caller does not have the required permission. |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The path specified in sourceFileName or destFileName is invalid, (for example, it is on an unmapped drive). |
T:System.NotSupportedException | sourceFileName or destFileName is in an invalid format. |
|
static |
Opens a T:System.IO.FileStream on the specified path with read/write access.
path | The file to open. |
mode | A T:System.IO.FileMode 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. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid, (for example, it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.UnauthorizedAccessException | path specified a file that is read-only.-or- This operation is not supported on the current platform.-or- path specified a directory.-or- The caller does not have the required permission. -or- mode is F:System.IO.FileMode.Create and the specified file is a hidden file. |
T:System.ArgumentOutOfRangeException | mode specified an invalid value. |
T:System.IO.FileNotFoundException | The file specified in path was not found. |
T:System.NotSupportedException | path is in an invalid format. |
|
static |
Opens a T:System.IO.FileStream on the specified path, with the specified mode and access.
path | The file to open. |
mode | A T:System.IO.FileMode 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. |
access | A T:System.IO.FileAccess value that specifies the operations that can be performed on the file. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars.-or- access specified Read and mode specified Create , CreateNew , Truncate , or Append . |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid, (for example, it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.UnauthorizedAccessException | path specified a file that is read-only and access is not Read .-or- path specified a directory.-or- The caller does not have the required permission. -or- mode is F:System.IO.FileMode.Create and the specified file is a hidden file. |
T:System.ArgumentOutOfRangeException | mode or access specified an invalid value. |
T:System.IO.FileNotFoundException | The file specified in path was not found. |
T:System.NotSupportedException | path is in an invalid format. |
|
static |
Opens a T:System.IO.FileStream on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option.
path | The file to open. |
mode | A T:System.IO.FileMode 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. |
access | A T:System.IO.FileAccess value that specifies the operations that can be performed on the file. |
share | A T:System.IO.FileShare value specifying the type of access other threads have to the file. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars.-or- access specified Read and mode specified Create , CreateNew , Truncate , or Append . |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid, (for example, it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.UnauthorizedAccessException | path specified a file that is read-only and access is not Read .-or- path specified a directory.-or- The caller does not have the required permission. -or- mode is F:System.IO.FileMode.Create and the specified file is a hidden file. |
T:System.ArgumentOutOfRangeException | mode , access , or share specified an invalid value. |
T:System.IO.FileNotFoundException | The file specified in path was not found. |
T:System.NotSupportedException | path is in an invalid format. |
|
static |
Opens an existing file for reading.
path | The file to be opened for reading. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid, (for example, it is on an unmapped drive). |
T:System.UnauthorizedAccessException | path specified a directory.-or- The caller does not have the required permission. |
T:System.IO.FileNotFoundException | The file specified in path was not found. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.IO.IOException | An I/O error occurred while opening the file. |
|
static |
Opens an existing UTF-8 encoded text file for reading.
path | The file to be opened for reading. |
T:System.UnauthorizedAccessException | The caller does not have the required permission. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid, (for example, it is on an unmapped drive). |
T:System.IO.FileNotFoundException | The file specified in path was not found. |
T:System.NotSupportedException | path is in an invalid format. |
|
static |
Opens an existing file or creates a new file for writing.
path | The file to be opened for writing. |
T:System.UnauthorizedAccessException | The caller does not have the required permission.-or- path specified a read-only file or directory. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid, (for example, it is on an unmapped drive). |
T:System.NotSupportedException | path is in an invalid format. |
|
static |
Opens a binary file, reads the contents of the file into a byte array, and then closes the file.
path | The file to open for reading. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid (for example, it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.UnauthorizedAccessException | This operation is not supported on the current platform.-or- path specified a directory.-or- The caller does not have the required permission. |
T:System.IO.FileNotFoundException | The file specified in path was not found. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.Security.SecurityException | The caller does not have the required permission. |
|
static |
Opens a text file, reads all lines of the file, and then closes the file.
path | The file to open for reading. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid (for example, it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.UnauthorizedAccessException | path specified a file that is read-only.-or- This operation is not supported on the current platform.-or- path specified a directory.-or- The caller does not have the required permission. |
T:System.IO.FileNotFoundException | The file specified in path was not found. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.Security.SecurityException | The caller does not have the required permission. |
|
static |
Opens a file, reads all lines of the file with the specified encoding, and then closes the file.
path | The file to open for reading. |
encoding | The encoding applied to the contents of the file. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid (for example, it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.UnauthorizedAccessException | path specified a file that is read-only.-or- This operation is not supported on the current platform.-or- path specified a directory.-or- The caller does not have the required permission. |
T:System.IO.FileNotFoundException | The file specified in path was not found. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.Security.SecurityException | The caller does not have the required permission. |
|
static |
Opens a text file, reads all lines of the file, and then closes the file.
path | The file to open for reading. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid (for example, it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.UnauthorizedAccessException | path specified a file that is read-only.-or- This operation is not supported on the current platform.-or- path specified a directory.-or- The caller does not have the required permission. |
T:System.IO.FileNotFoundException | The file specified in path was not found. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.Security.SecurityException | The caller does not have the required permission. |
|
static |
Opens a file, reads all lines of the file with the specified encoding, and then closes the file.
path | The file to open for reading. |
encoding | The encoding applied to the contents of the file. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid (for example, it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.UnauthorizedAccessException | path specified a file that is read-only.-or- This operation is not supported on the current platform.-or- path specified a directory.-or- The caller does not have the required permission. |
T:System.IO.FileNotFoundException | The file specified in path was not found. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.Security.SecurityException | The caller does not have the required permission. |
|
static |
Reads the lines of a file.
path | The file to read. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters defined by the M:System.IO.Path.GetInvalidPathChars method. |
T:System.ArgumentNullException | path is null . |
T:System.IO.DirectoryNotFoundException | path is invalid (for example, it is on an unmapped drive). |
T:System.IO.FileNotFoundException | The file specified by path was not found. |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.IO.PathTooLongException | path 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. |
T:System.Security.SecurityException | The caller does not have the required permission. |
T:System.UnauthorizedAccessException | path specifies a file that is read-only.-or-This operation is not supported on the current platform.-or- path is a directory.-or-The caller does not have the required permission. |
|
static |
Read the lines of a file that has a specified encoding.
path | The file to read. |
encoding | The encoding that is applied to the contents of the file. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by the M:System.IO.Path.GetInvalidPathChars method. |
T:System.ArgumentNullException | path is null . |
T:System.IO.DirectoryNotFoundException | path is invalid (for example, it is on an unmapped drive). |
T:System.IO.FileNotFoundException | The file specified by path was not found. |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.IO.PathTooLongException | path 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. |
T:System.Security.SecurityException | The caller does not have the required permission. |
T:System.UnauthorizedAccessException | path specifies a file that is read-only.-or-This operation is not supported on the current platform.-or- path is a directory.-or-The caller does not have the required permission. |
|
static |
Replaces the contents of a specified file with the contents of another file, deleting the original file, and creating a backup of the replaced file.
sourceFileName | The name of a file that replaces the file specified by destinationFileName . |
destinationFileName | The name of the file being replaced. |
destinationBackupFileName | The name of the backup file. |
T:System.ArgumentException | The path described by the destinationFileName parameter was not of a legal form.-or-The path described by the destinationBackupFileName parameter was not of a legal form. |
T:System.ArgumentNullException | The destinationFileName parameter is null . |
T:System.IO.DriveNotFoundException | An invalid drive was specified. |
T:System.IO.FileNotFoundException | The file described by the current T:System.IO.FileInfo object could not be found.-or-The file described by the destinationBackupFileName parameter could not be found. |
T:System.IO.IOException | An I/O error occurred while opening the file.- or -The sourceFileName and destinationFileName parameters specify the same file. |
T:System.IO.PathTooLongException | 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. |
T:System.PlatformNotSupportedException | The operating system is Windows 98 Second Edition or earlier and the files system is not NTFS. |
T:System.UnauthorizedAccessException | The sourceFileName or destinationFileName parameter specifies a file that is read-only.-or- This operation is not supported on the current platform.-or- Source or destination parameters specify a directory instead of a file.-or- The caller does not have the required permission. |
|
static |
Replaces the contents of a specified file with the contents of another file, deleting the original file, and creating a backup of the replaced file and optionally ignores merge errors.
sourceFileName | The name of a file that replaces the file specified by destinationFileName . |
destinationFileName | The name of the file being replaced. |
destinationBackupFileName | The name of the backup file. |
ignoreMetadataErrors | true to ignore merge errors (such as attributes and access control lists (ACLs)) from the replaced file to the replacement file; otherwise, false . |
T:System.ArgumentException | The path described by the destinationFileName parameter was not of a legal form.-or-The path described by the destinationBackupFileName parameter was not of a legal form. |
T:System.ArgumentNullException | The destinationFileName parameter is null . |
T:System.IO.DriveNotFoundException | An invalid drive was specified. |
T:System.IO.FileNotFoundException | The file described by the current T:System.IO.FileInfo object could not be found.-or-The file described by the destinationBackupFileName parameter could not be found. |
T:System.IO.IOException | An I/O error occurred while opening the file.- or -The sourceFileName and destinationFileName parameters specify the same file. |
T:System.IO.PathTooLongException | 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. |
T:System.PlatformNotSupportedException | The operating system is Windows 98 Second Edition or earlier and the files system is not NTFS. |
T:System.UnauthorizedAccessException | The sourceFileName or destinationFileName parameter specifies a file that is read-only.-or- This operation is not supported on the current platform.-or- Source or destination parameters specify a directory instead of a file.-or- The caller does not have the required permission. |
|
static |
Applies access control list (ACL) entries described by a T:System.Security.AccessControl.FileSecurity object to the specified file.
path | A file to add or remove access control list (ACL) entries from. |
fileSecurity | A T:System.Security.AccessControl.FileSecurity object that describes an ACL entry to apply to the file described by the path parameter. |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.Runtime.InteropServices.SEHException | The path parameter is null . |
T:System.SystemException | The file could not be found. |
T:System.UnauthorizedAccessException | The path parameter specified a file that is read-only.-or- This operation is not supported on the current platform.-or- The path parameter specified a directory.-or- The caller does not have the required permission. |
T:System.ArgumentNullException | The fileSecurity parameter is null . |
|
static |
Sets the specified T:System.IO.FileAttributes of the file on the specified path.
path | The path to the file. |
fileAttributes | A bitwise combination of the enumeration values. |
T:System.ArgumentException | path is empty, contains only white spaces, contains invalid characters, or the file attribute is invalid. |
T:System.IO.PathTooLongException | 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. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid, (for example, it is on an unmapped drive). |
T:System.IO.FileNotFoundException | The file cannot be found. |
T:System.UnauthorizedAccessException | path specified a file that is read-only.-or- This operation is not supported on the current platform.-or- path specified a directory.-or- The caller does not have the required permission. |
|
static |
Sets the date and time the file was created.
path | The file for which to set the creation date and time information. |
creationTime | A T:System.DateTime containing the value to set for the creation date and time of path . This value is expressed in local time. |
T:System.IO.FileNotFoundException | The specified path was not found. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.IOException | An I/O error occurred while performing the operation. |
T:System.ArgumentOutOfRangeException | creationTime specifies a value outside the range of dates, times, or both permitted for this operation. |
T:System.UnauthorizedAccessException | The caller does not have the required permission. |
T:System.NotSupportedException | path is in an invalid format. |
|
static |
Sets the date and time, in coordinated universal time (UTC), that the file was created.
path | The file for which to set the creation date and time information. |
creationTimeUtc | A T:System.DateTime containing the value to set for the creation date and time of path . This value is expressed in UTC time. |
T:System.IO.FileNotFoundException | The specified path was not found. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.IOException | An I/O error occurred while performing the operation. |
T:System.ArgumentOutOfRangeException | creationTime specifies a value outside the range of dates, times, or both permitted for this operation. |
T:System.UnauthorizedAccessException | The caller does not have the required permission. |
T:System.NotSupportedException | path is in an invalid format. |
|
static |
Sets the date and time the specified file was last accessed.
path | The file for which to set the access date and time information. |
lastAccessTime | A T:System.DateTime containing the value to set for the last access date and time of path . This value is expressed in local time. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.FileNotFoundException | The specified path was not found. |
T:System.UnauthorizedAccessException | The caller does not have the required permission. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.ArgumentOutOfRangeException | lastAccessTime specifies a value outside the range of dates or times permitted for this operation. |
|
static |
Sets the date and time, in coordinated universal time (UTC), that the specified file was last accessed.
path | The file for which to set the access date and time information. |
lastAccessTimeUtc | A T:System.DateTime containing the value to set for the last access date and time of path . This value is expressed in UTC time. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.FileNotFoundException | The specified path was not found. |
T:System.UnauthorizedAccessException | The caller does not have the required permission. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.ArgumentOutOfRangeException | lastAccessTimeUtc specifies a value outside the range of dates or times permitted for this operation. |
|
static |
Sets the date and time that the specified file was last written to.
path | The file for which to set the date and time information. |
lastWriteTime | A T:System.DateTime containing the value to set for the last write date and time of path . This value is expressed in local time. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.FileNotFoundException | The specified path was not found. |
T:System.UnauthorizedAccessException | The caller does not have the required permission. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.ArgumentOutOfRangeException | lastWriteTime specifies a value outside the range of dates or times permitted for this operation. |
|
static |
Sets the date and time, in coordinated universal time (UTC), that the specified file was last written to.
path | The file for which to set the date and time information. |
lastWriteTimeUtc | A T:System.DateTime containing the value to set for the last write date and time of path . This value is expressed in UTC time. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.FileNotFoundException | The specified path was not found. |
T:System.UnauthorizedAccessException | The caller does not have the required permission. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.ArgumentOutOfRangeException | lastWriteTimeUtc specifies a value outside the range of dates or times permitted for this operation. |
|
static |
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.
path | The file to write to. |
bytes | The bytes to write to the file. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null or the byte array is empty. |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid (for example, it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.UnauthorizedAccessException | path specified a file that is read-only.-or- This operation is not supported on the current platform.-or- path specified a directory.-or- The caller does not have the required permission. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.Security.SecurityException | The caller does not have the required permission. |
|
static |
Creates a new file, write the specified string array to the file, and then closes the file.
path | The file to write to. |
contents | The string array to write to the file. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | Either path or contents is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid (for example, it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.UnauthorizedAccessException | path specified a file that is read-only.-or- This operation is not supported on the current platform.-or- path specified a directory.-or- The caller does not have the required permission. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.Security.SecurityException | The caller does not have the required permission. |
|
static |
Creates a new file, writes the specified string array to the file by using the specified encoding, and then closes the file.
path | The file to write to. |
contents | The string array to write to the file. |
encoding | An T:System.Text.Encoding object that represents the character encoding applied to the string array. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | Either path or contents is null . |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid (for example, it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.UnauthorizedAccessException | path specified a file that is read-only.-or- This operation is not supported on the current platform.-or- path specified a directory.-or- The caller does not have the required permission. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.Security.SecurityException | The caller does not have the required permission. |
|
static |
Creates a new file, writes a collection of strings to the file, and then closes the file.
path | The file to write to. |
contents | The lines to write to the file. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters defined by the M:System.IO.Path.GetInvalidPathChars method. |
T:System.ArgumentNullException | Either path or contents is null . |
T:System.IO.DirectoryNotFoundException | path is invalid (for example, it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.IO.PathTooLongException | path 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. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.Security.SecurityException | The caller does not have the required permission. |
T:System.UnauthorizedAccessException | path specifies a file that is read-only.-or-This operation is not supported on the current platform.-or- path is a directory.-or-The caller does not have the required permission. |
|
static |
Creates a new file by using the specified encoding, writes a collection of strings to the file, and then closes the file.
path | The file to write to. |
contents | The lines to write to the file. |
encoding | The character encoding to use. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters defined by the M:System.IO.Path.GetInvalidPathChars method. |
T:System.ArgumentNullException | Either path , contents , or encoding is null . |
T:System.IO.DirectoryNotFoundException | path is invalid (for example, it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.IO.PathTooLongException | path 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. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.Security.SecurityException | The caller does not have the required permission. |
T:System.UnauthorizedAccessException | path specifies a file that is read-only.-or-This operation is not supported on the current platform.-or- path is a directory.-or-The caller does not have the required permission. |
|
static |
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.
path | The file to write to. |
contents | The string to write to the file. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null or contents is empty. |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid (for example, it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.UnauthorizedAccessException | path specified a file that is read-only.-or- This operation is not supported on the current platform.-or- path specified a directory.-or- The caller does not have the required permission. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.Security.SecurityException | The caller does not have the required permission. |
|
static |
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.
path | The file to write to. |
contents | The string to write to the file. |
encoding | The encoding to apply to the string. |
T:System.ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by F:System.IO.Path.InvalidPathChars. |
T:System.ArgumentNullException | path is null or contents is empty. |
T:System.IO.PathTooLongException | 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. |
T:System.IO.DirectoryNotFoundException | The specified path is invalid (for example, it is on an unmapped drive). |
T:System.IO.IOException | An I/O error occurred while opening the file. |
T:System.UnauthorizedAccessException | path specified a file that is read-only.-or- This operation is not supported on the current platform.-or- path specified a directory.-or- The caller does not have the required permission. |
T:System.NotSupportedException | path is in an invalid format. |
T:System.Security.SecurityException | The caller does not have the required permission. |