System.IO.File Class

public sealed class File

Base Types

Object
  File

Assembly

mscorlib

Library

BCL

Summary

Provides information and performs operations on files .

Description

Implementations of this class are required to preserve the case of path strings. Implementations are required to be case sensitive if and only if the platform is case-sensitive.

The following table describes the enumerations that are used to customize the behavior of various File methods.

EnumerationDescription
FileAccessSpecifies read and write access to a file.
FileShareSpecifies the level of access permitted for a file that is already in use.
FileModeSpecifies whether the contents of an existing file are preserved or overwritten, and whether requests to create an existing file cause an exception.

See Also

System.IO Namespace

Members

File Methods

File.AppendText Method
File.Copy(System.String, System.String) Method
File.Copy(System.String, System.String, bool) Method
File.Create(System.String) Method
File.Create(System.String, int) Method
File.CreateText Method
File.Delete Method
File.Exists Method
File.GetCreationTime Method
File.GetLastAccessTime Method
File.GetLastWriteTime Method
File.Move Method
File.Open(System.String, System.IO.FileMode) Method
File.Open(System.String, System.IO.FileMode, System.IO.FileAccess) Method
File.Open(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare) Method
File.OpenRead Method
File.OpenText Method
File.OpenWrite Method
File.SetCreationTime Method
File.SetLastAccessTime Method
File.SetLastWriteTime Method


File.AppendText Method

public static StreamWriter AppendText(string path);

Summary

Appends UTF-8 encoded text to an existing file.

Parameters

path
A String containing the name of the file to append to.

Return Value

A StreamWriter that appends UTF-8 encoded text to the specified file.

Exceptions

Exception TypeCondition
SecurityExceptionThe caller does not have the required permission.
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more invalid characters.
FileNotFoundExceptionpath was not found.
ArgumentNullExceptionpath is null .
DirectoryNotFoundExceptionThe directory information specified in path was not found.
PathTooLongExceptionThe length of path or the absolute path information for path exceeds the system-defined maximum length.

Description

This method is equivalent to StreamWriter (path, true ). If the file specified by path does not exist, it is created. If the file does exist, writes to the StreamWriter append text to the file. Additional threads are permitted to read the file while it is open.

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

See Also

System.IO.File Class, System.IO Namespace

File.Copy(System.String, System.String) Method

public static void Copy(string sourceFileName, string destFileName);

Summary

Copies the specified file to a new location.

Parameters

sourceFileName
A String containing the name of the file to copy.
destFileName
A String containing the name of the destination file. Cannot specify a directory or an existing file.

Exceptions

Exception TypeCondition
IOExceptiondestFileName exists.

-or-

An I/O error occurred.

ArgumentNullExceptionsourceFileName or destFileName is null .
ArgumentExceptionsourceFileName or destFileName is a zero-length string, contains only white space, or contains one or more implementation-defined invalid characters.

-or-

sourceFileName or destFileName specifies a directory.

SecurityExceptionThe caller does not have the required permission.
DirectoryNotFoundExceptionDirectory information in sourceFileName or destFileName was not found.
FileNotFoundExceptionsourceFileName was not found.
PathTooLongExceptionThe length or the absolute path information for sourceFileName or destFileName exceeds the system-defined maximum length.

Description

This method is equivalent to System.IO.File.Copy(System.String,System.String) (sourceFileName, destFileName, false ).

The sourceFileName and destFileName arguments are permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

See Also

System.IO.File Class, System.IO Namespace

File.Copy(System.String, System.String, bool) Method

public static void Copy(string sourceFileName, string destFileName, bool overwrite);

Summary

Copies the specified file to a new location.

Parameters

sourceFileName
A String containing the name of the file to copy.
destFileName
A String containing the name of the destination file. Cannot specify the name of a directory.
overwrite
A Boolean value. Specify true if the destination file can be overwritten; otherwise false .

Exceptions

Exception TypeCondition
IOExceptiondestFileName is read-only (write-protected), or destFileName exists and overwrite is false .

-or-

An I/O error occurred.

ArgumentNullExceptionsourceFileName or destFileName is null .
ArgumentExceptionsourceFileName or destFileName is a zero-length string, contains only white space, or contains one or more invalid characters.

-or-

sourceFileName or destFileName specifies a directory.

SecurityExceptionThe caller does not have the required permission.
DirectoryNotFoundExceptionDirectory information in destFileName or sourceFileName was not found.
FileNotFoundExceptionsourceFileName was not found.
PathTooLongExceptionThe length or the absolute path information for sourceFileName or destFileName exceeds the system-defined maximum length.

Description

The sourceFileName and destFileName arguments are permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

See Also

System.IO.File Class, System.IO Namespace

File.Create(System.String) Method

public static FileStream Create(string path);

Summary

Creates or overwrites the specified file.

Parameters

path
A String containing the name of the file.

Return Value

A FileStream that provides read/write access to the specified file.

Exceptions

Exception TypeCondition
SecurityExceptionThe caller does not have the required permission.
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more implementation-defined invalid characters.

ArgumentNullExceptionpath is null .
DirectoryNotFoundExceptionThe directory information specified in path was not found.
IOExceptionAn I/O error occurred while creating the file.
UnauthorizedAccessExceptionpath specified a file that is read-only (write-protected).
PathTooLongExceptionThe length of path or the absolute path information for path exceeds the system-defined maximum length.

Description

This method is equivalent to System.IO.File.Create(System.String) (path, System.IO.FileStream.DefaultBufferSize ).

If the specified file does not exist, it is created; if it does exist and it is not read-only, the contents are overwritten.

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

See Also

System.IO.File Class, System.IO Namespace

File.Create(System.String, int) Method

public static FileStream Create(string path, int bufferSize);

Summary

Creates or overwrites the specified file.

Parameters

path
A String containing the name of the file.
bufferSize
A Int32 containing the number of bytes buffered for reads and writes to the file.

Return Value

A FileStream that provides read/write access to the specified file.

Exceptions

Exception TypeCondition
SecurityExceptionThe caller does not have the required permission.
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more implementation-defined invalid characters.

ArgumentNullExceptionpath is null .
DirectoryNotFoundExceptionThe directory information specified in path was not found.
IOExceptionAn I/O error occurred while creating the file.
UnauthorizedAccessExceptionpath specified a file that is read-only (write-protected).
PathTooLongExceptionThe length of path or the absolute path information for path exceeds the system-defined maximum length.

Description

This method is equivalent to FileStream (path, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite, System.IO.FileShare.None , bufferSize).

If the specified file does not exist, it is created; if it does exist and it is not read-only, the contents are overwritten.

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

See Also

System.IO.File Class, System.IO Namespace

File.CreateText Method

public static StreamWriter CreateText(string path);

Summary

Creates or opens a new file for writing UTF-8 encoded text.

Parameters

path
The file to be opened for writing.

Return Value

A StreamWriter that writes to the specified file using UTF-8 encoding.

Exceptions

Exception TypeCondition
SecurityExceptionThe caller does not have the required permission.
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more invalid characters.
ArgumentNullExceptionpath is null .
DirectoryNotFoundExceptionThe directory information specified in path was not found.
PathTooLongExceptionThe length of path or the absolute path information for path exceeds the system-defined maximum length.

Description

This method is equivalent to StreamWriter (path, false ). If the file specified by path does not exist, it is created. If the file does exist, its contents are overwritten. Additional threads are permitted to read the file while it is open.

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.

See Also

System.IO.File Class, System.IO Namespace

File.Delete Method

public static void Delete(string path);

Summary

Deletes the specified file.

Parameters

path
A String containing the name of the file to be deleted.

Exceptions

Exception TypeCondition
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more implementation-defined invalid characters.
ArgumentNullExceptionpath is null .
DirectoryNotFoundExceptionThe directory information specified in path was not found.
IOExceptionThe specified file is in use.
SecurityExceptionThe caller does not have the required permission.
UnauthorizedAccessExceptionpath identifies a directory.
PathTooLongExceptionThe length of path or the absolute path information for path exceeds the system-defined maximum length.

Description

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

See Also

System.IO.File Class, System.IO Namespace

File.Exists Method

public static bool Exists(string path);

Summary

Returns a Boolean indicating whether the specified file exists.

Parameters

path
A String containing the name of the file to check.

Return Value

true if the caller has the required permissions and path contains the name of an existing file; otherwise, false . If path is null or a zero-length string, returns false .

Description

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.

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

See Also

System.IO.File Class, System.IO Namespace

File.GetCreationTime Method

public static DateTime GetCreationTime(string path);

Summary

Returns the creation date and time of the specified file or directory.

Parameters

path
A String containing the name of the file or directory for which to obtain creation date and time information.

Return Value

A DateTime structure set to the creation date and time for the specified file or directory. This value is expressed in local time.

Platforms that do not support this feature return System.DateTime.MinValue.

Exceptions

Exception TypeCondition
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more implementation-defined invalid characters.
ArgumentNullExceptionpath is null .
IOExceptionpath was not found.
PathTooLongExceptionThe length of path or the absolute path information for path exceeds the system-defined maximum length.
SecurityExceptionThe caller does not have the required permission.

Description

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

See Also

System.IO.File Class, System.IO Namespace

File.GetLastAccessTime Method

public static DateTime GetLastAccessTime(string path);

Summary

Returns the date and time the specified file or directory was last accessed.

Parameters

path
A String containing the name of the file or directory for which to obtain access date and time information.

Return Value

A DateTime structure set to the date and time the specified file or directory was last accessed. This value is expressed in local time.

Platforms that do not support this feature return System.DateTime.MinValue.

Exceptions

Exception TypeCondition
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more implementation-defined invalid characters.
ArgumentNullExceptionpath is null .
IOExceptionpath was not found.
PathTooLongExceptionThe length of path or the absolute path information for path exceeds the system-defined maximum length.
SecurityExceptionThe caller does not have the required permission.

Description

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

See Also

System.IO.File Class, System.IO Namespace

File.GetLastWriteTime Method

public static DateTime GetLastWriteTime(string path);

Summary

Returns the date and time the specified file or directory was last written to.

Parameters

path
A String containing the name of the file for which to obtain write date and time information.

Return Value

A DateTime structure set to the date and time the specified file or directory was last written to. This value is expressed in local time.

Platforms that do not support this feature return System.DateTime.MinValue.

Exceptions

Exception TypeCondition
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more implementation-defined invalid characters.
ArgumentNullExceptionpath is null .
IOExceptionpath was not found.
PathTooLongExceptionThe length of path or the absolute path information for path exceeds the system-defined maximum length.
SecurityExceptionThe caller does not have the required permission.

Description

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

See Also

System.IO.File Class, System.IO Namespace

File.Move Method

public static void Move(string sourceFileName, string destFileName);

Summary

Moves the specified file to a new location.

Parameters

sourceFileName
A String containing the name of the file to move.
destFileName
A String containing the name of the new location for the file.

Exceptions

Exception TypeCondition
IOExceptionThe destination file is read-only or destFileName is a directory.
ArgumentNullExceptionsourceFileName or destFileName is null .
ArgumentExceptionsourceFileName or destFileName is a zero-length string, contains only white space, or contains one or more implementation-defined invalid characters.

SecurityExceptionThe caller does not have the required permission.
DirectoryNotFoundExceptionThe directory information in sourceFileName or destFileName was not found.
FileNotFoundExceptionsourceFileName was not found or specifies a directory.
PathTooLongExceptionThe length or absolute path information for sourceFileName or destFileName exceeds the system-defined maximum length.

Description

This method does not throw an exception if the source and destination are the same.

The sourceFileName and destFileName arguments are permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

See Also

System.IO.File Class, System.IO Namespace

File.Open(System.String, System.IO.FileMode) Method

public static FileStream Open(string path, FileMode mode);

Summary

Opens a FileStream on the specified file with read/write access.

Parameters

path
A String containing the name of the file to open.
mode
A 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.

Return Value

A FileStream that provides read/write access to the specified file.

Exceptions

Exception TypeCondition
SecurityExceptionThe caller does not have the required permission.
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more implementation-defined invalid characters.

FileNotFoundExceptionpath was not found.
ArgumentNullExceptionpath is null .
ArgumentOutOfRangeExceptionmode specified an invalid value.
DirectoryNotFoundExceptionThe directory information specified in path was not found.
IOExceptionAn I/O error occurred while opening the file.
UnauthorizedAccessExceptionpath specified a read-only file (this method attempts to open the file with read/write access).

-or-

This operation is not supported on the current platform.

-or-

path specified a directory.

PathTooLongExceptionThe length of path or the absolute path information for path exceeds the system-defined maximum length.

Description

This method is equivalent to FileStream (path, mode, System.IO.FileAccess.ReadWrite, System.IO.FileShare.None ).

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

See Also

System.IO.File Class, System.IO Namespace

File.Open(System.String, System.IO.FileMode, System.IO.FileAccess) Method

public static FileStream Open(string path, FileMode mode, FileAccess access);

Summary

Opens a FileStream on the specified file.

Parameters

path
A String containing the name of the file to open.
mode
A 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 FileAccess value that specifies the operations that can be performed on the file.

Return Value

A FileStream that provides access to the specified file.

Exceptions

Exception TypeCondition
SecurityExceptionThe caller does not have the required permission.
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more implementation-defined invalid characters.

-or-

access specified Read and mode specified Create , CreateNew , Truncate or Append .

FileNotFoundExceptionpath was not found.
ArgumentNullExceptionpath is null .
ArgumentOutOfRangeExceptionmode or access specified an invalid value.
DirectoryNotFoundExceptionThe directory information specified in path was not found.
IOExceptionAn I/O error occurred while opening the file.
UnauthorizedAccessExceptionpath specified a read-only file and access is not Read , or path specified a directory.
PathTooLongExceptionThe length of path or the absolute path information for path exceeds the system-defined maximum length.

Description

This method is equivalent to FileStream (path, mode, access, System.IO.FileShare.None ).

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

See Also

System.IO.File Class, System.IO Namespace

File.Open(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare) Method

public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share);

Summary

Opens a FileStream on the specified file.

Parameters

path
A String containing the name of the file to open.
mode
A 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 FileAccess value that specifies the operations that can be performed on the file.
share
A FileShare value specifying the type of access other threads have to the file.

Return Value

A FileStream that provides access to the specified file.

Exceptions

Exception TypeCondition
SecurityExceptionThe caller does not have the required permission.
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more implementation-defined invalid characters.

-or-

access specified Read and mode specified Create , CreateNew , Truncate or Append .

FileNotFoundExceptionpath was not found.
ArgumentNullExceptionpath is null .
ArgumentOutOfRangeExceptionmode, access, or share specified an invalid value.
DirectoryNotFoundExceptionThe directory information specified in path was not found.
IOExceptionAn I/O error occurred while opening the file.
UnauthorizedAccessExceptionpath specified a read-only file and access is not Read , or path specified a directory.
PathTooLongExceptionThe length of path or the absolute path information for path exceeds the system-defined maximum length.

Description

This method is equivalent to FileStream (path, mode, access, share).

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

See Also

System.IO.File Class, System.IO Namespace

File.OpenRead Method

public static FileStream OpenRead(string path);

Summary

Opens an existing file for reading.

Parameters

path
A String containing the name of the file to be opened for reading.

Return Value

A read-only FileStream containing the contents of the specified file.

Exceptions

Exception TypeCondition
SecurityExceptionThe caller does not have the required permission.
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more implementation-defined invalid characters.
FileNotFoundExceptionpath was not found.
ArgumentNullExceptionpath is null .
DirectoryNotFoundExceptionThe directory information specified in path was not found.
UnauthorizedAccessExceptionpath specified a read-only (write-protected) file or a directory.
PathTooLongExceptionThe length of path or the absolute path information for path exceeds the system-defined maximum length.

Description

This method is equivalent to FileStream (path, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read ).

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

See Also

System.IO.File Class, System.IO Namespace

File.OpenText Method

public static StreamReader OpenText(string path);

Summary

Opens an existing UTF-8 encoded text file for reading.

Parameters

path
A String containing the name of the file to be opened for reading.

Return Value

A StreamReader containing the contents of the specified file.

Exceptions

Exception TypeCondition
SecurityExceptionThe caller does not have the required permission.
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more implementation-defined invalid characters.
FileNotFoundExceptionpath was not found.
ArgumentNullExceptionpath is null .
DirectoryNotFoundExceptionThe directory information specified in path was not found.
PathTooLongExceptionThe length of path or the absolute path information for path exceeds the system-defined maximum length.

Description

This method is equivalent to StreamReader (path).

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

See Also

System.IO.File Class, System.IO Namespace

File.OpenWrite Method

public static FileStream OpenWrite(string path);

Summary

Opens an existing file for writing.

Parameters

path
A String containing the name of the file to be opened for writing.

Return Value

A writable FileStream that writes to the file specified by path.

Exceptions

Exception TypeCondition
SecurityExceptionThe caller does not have the required permission.
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more implementation-defined invalid characters.
FileNotFoundExceptionpath was not found.
ArgumentNullExceptionpath is null .
DirectoryNotFoundExceptionThe directory information specified in path was not found.
UnauthorizedAccessExceptionpath specified a read-only file or a directory.
PathTooLongExceptionThe length of path or the absolute path information for path exceeds the system-defined maximum length.

Description

This method is equivalent to FileStream (path, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, System.IO.FileShare.None ).

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

See Also

System.IO.File Class, System.IO Namespace

File.SetCreationTime Method

public static void SetCreationTime(string path, DateTime creationTime);

Summary

Sets the creation date and time for the specified file.

Parameters

path
A String containing the name of the file for which to set the creation date and time information.
creationTime
A DateTime containing the value to set for the creation date and time of path. This value is expressed in local time.

Exceptions

Exception TypeCondition
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more implementation-defined invalid characters.
ArgumentOutOfRangeExceptioncreationTime specifies a value outside the range of date/times permitted for this operation.
ArgumentNullExceptionpath is null .
FileNotFoundExceptionpath was not found.
IOExceptionAn I/O error occurred while performing the operation.
PathTooLongExceptionThe length of path or the absolute path information for path exceeds the system-defined maximum length.

Description

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

On platforms that do not support this feature, this method has no effect. If this feature is supported, the range of dates that is valid for this operation is implementation-specific.

See Also

System.IO.File Class, System.IO Namespace

File.SetLastAccessTime Method

public static void SetLastAccessTime(string path, DateTime lastAccessTime);

Summary

Sets the date and time the specified file was last accessed.

Parameters

path
A String containing the name of the file for which to set the access date and time information.
lastAccessTime
A DateTime containing the value to set for the access date and time of path. This value is expressed in local time.

Exceptions

Exception TypeCondition
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more implementation-defined invalid characters.
ArgumentNullExceptionpath is null .
IOExceptionpath was not found.
PathTooLongExceptionThe length of path or the absolute path information for path exceeds the system-defined maximum length.
SecurityExceptionThe caller does not have the required permission.

Description

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

On platforms that do not support this feature, this method has no effect. If this feature is supported, the range of dates that is valid for this operation is implementation-specific.

See Also

System.IO.File Class, System.IO Namespace

File.SetLastWriteTime Method

public static void SetLastWriteTime(string path, DateTime lastWriteTime);

Summary

Sets the date and time a file was last written to.

Parameters

path
A String containing the name of the file for which to set the date and time information.
lastWriteTime
A DateTime containing the value to set for the last write date and time of path. This value is expressed in local time.

Exceptions

Exception TypeCondition
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more implementation-defined invalid characters.
ArgumentNullExceptionpath is null .
IOExceptionpath was not found.
PathTooLongExceptionThe length of path or the absolute path information for path exceeds the system-defined maximum length.
SecurityExceptionThe caller does not have the required permission.

Description

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. [Note: To obtain the current working directory, see System.IO.Directory.GetCurrentDirectory.]

On platforms that do not support this feature, this method has no effect. If this feature is supported, the range of dates that is valid for this operation is implementation-specific.

See Also

System.IO.File Class, System.IO Namespace