FileSystem.MoveFile Method (String, String)
Moves a file to a new location.
Assembly: Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\.\); it ends with a trailing slash.
destinationFileName is Nothing or an empty string.
The source file is not valid or does not exist.
The file is in use by another process, or an I/O error occurs.
The path exceeds the system-defined maximum length.
A file or directory name in the path contains a colon (:) or is in an invalid format.
The user lacks necessary permissions to view the path.
If the target structure does not exist, it is created.
The MoveFile method preserves ACEs (Access Control Entries) only when moving the file within the same volume. This includes inherited ACEs, which become direct ACEs when moved (direct ACEs take precedence over inherited ACEs). If a file is moved between volumes, ACEs will not be copied.
The following table lists examples of tasks involving the My.Computer.FileSystem.MoveFile method.
Move a file
Move a collection of files
Move the contents of a directory
This example moves the file Test.txt from TestDir1 to TestDir2.
This example moves the file Test.txt from TestDir1 to TestDir2 and renames it Test2.txt.
Controls the ability to access all environment variables. Associated enumeration: Unrestricted.
Controls the ability to access files and folders. Associated enumeration: Unrestricted.
Controls the ability to access registry variables. Associated enumeration: Unrestricted.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.