Mono Class Library: System.IO.File Overview | Members

System.IO.File.Move Method

Moves the specified file to a new location. [Edit]

public static void Move (string sourceFileName, string destFileName)

Parameters

sourceFileName
A string containing the name of the file to move. [Edit]
destFileName
A string containing the name of the new location for the file. [Edit]

Permissions

TypeReason
System.Security.Permissions.FileIOPermission [Edit] Requires permission to read from sourceFileName, and write to sourceFileName and destFileName. See System.Security.Permissions.FileIOPermissionAccess.Read and System.Security.Permissions.FileIOPermissionAccess.Write.

Exceptions

TypeReason
System.IO.IOExceptiondestFileName already exists or is a directory. [Edit]
ArgumentNullExceptionsourceFileName or destFileName is null. [Edit]
ArgumentExceptionsourceFileName or destFileName is a zero-length string, contains only white space, or contains one or more implementation-specific invalid characters. [Edit]
System.Security.SecurityExceptionThe caller does not have the required permission. [Edit]
System.IO.DirectoryNotFoundExceptionThe directory information in sourceFileName or destFileName was not found. [Edit]
System.IO.FileNotFoundExceptionsourceFileName was not found or specifies a directory. [Edit]
System.IO.PathTooLongExceptionThe length or absolute path information for sourceFileName or destFileName exceeds the system-defined maximum length. [Edit]
UnauthorizedAccessExceptionThe caller does not have the required permission. [Edit]

Remarks

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 Directory.GetCurrentDirectory.

[Edit]

Requirements

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0