Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

FileSystemProxy.MoveDirectory Method (String, String)

Moves a directory from one location to another.

Namespace:  Microsoft.VisualBasic.MyServices
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public void MoveDirectory(
	string sourceDirectoryName,
	string destinationDirectoryName
)

Parameters

sourceDirectoryName
Type: System.String

Path of the directory to be moved.

destinationDirectoryName
Type: System.String

Path of the directory to which the source directory is being moved.

ExceptionCondition
ArgumentException

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 \\.\).

ArgumentNullException

sourceDirectoryName or destinationDirectoryName is Nothing or an empty string.

ArgumentNullException

sourceDirectoryName or destinationDirectoryName is Nothing or an empty string.

DirectoryNotFoundException

The directory does not exist.

IOException

The source is a root directory or The source path and the target path are the same.

PathTooLongException

The path exceeds the system-defined maximum length.

InvalidOperationException

The operation is cyclic.

NotSupportedException

A file or directory name in the path contains a colon (:) or is in an invalid format.

SecurityException

The user lacks necessary permissions to view the path.

UnauthorizedAccessException

The user does not have required permission.

If an attempt is made to move a directory inside a directory that does not exist, the target structure will be created.

This example moves Directory1 inside Directory2.

My.Computer.FileSystem.MoveDirectory("C:\Directory1", "C:\Directory2")

This example moves Directory1 inside Directory2, overwriting the directory if it already exists.

My.Computer.FileSystem.MoveDirectory("C:\Directory1", "C:\Directory2",
True)

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Show:
© 2015 Microsoft