Export (0) Print
Expand All

FileSystemProxy.MoveDirectory Method (String, String, UIOption)

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,
	UIOption showUI
)

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.
showUI
Type: Microsoft.VisualBasic.FileIO.UIOption
Specifies whether to visually track the operation's progress. Default is UIOption.OnlyErrorDialogs.

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.

IOException

The target directory already exists and overwrite is set to False.

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.

The following table lists an example of a task involving the My.Computer.FileSystem.MoveDirectory method.

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, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.

Community Additions

ADD
Show:
© 2014 Microsoft