FileSystemProxy.MoveDirectory Method

Definition

Moves a directory from one location to another.

Overloads

MoveDirectory(String, String)

Moves a directory from one location to another.

MoveDirectory(String, String, UIOption)

Moves a directory from one location to another.

MoveDirectory(String, String, Boolean)

Moves a directory from one location to another.

MoveDirectory(String, String, UIOption, UICancelOption)

Moves a directory from one location to another.

MoveDirectory(String, String)

Source:
FileSystemProxy.vb
Source:
FileSystemProxy.vb
Source:
FileSystemProxy.vb

Moves a directory from one location to another.

public void MoveDirectory (string sourceDirectoryName, string destinationDirectoryName);

Parameters

sourceDirectoryName
String

Path of the directory to be moved.

destinationDirectoryName
String

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

Exceptions

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

sourceDirectoryName or destinationDirectoryName is Nothing or an empty string.

The directory does not exist.

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

The path exceeds the system-defined maximum length.

The operation is cyclic.

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.

The user does not have required permission.

Examples

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)

Remarks

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

See also

Applies to

.NET Framework 4.8.1 og aðrar útgáfur
Vara Útgáfur
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 5, 6, 7, 8, 9

MoveDirectory(String, String, UIOption)

Source:
FileSystemProxy.vb
Source:
FileSystemProxy.vb
Source:
FileSystemProxy.vb

Moves a directory from one location to another.

public void MoveDirectory (string sourceDirectoryName, string destinationDirectoryName, Microsoft.VisualBasic.FileIO.UIOption showUI);

Parameters

sourceDirectoryName
String

Path of the directory to be moved.

destinationDirectoryName
String

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

showUI
UIOption

Specifies whether to visually track the operation's progress. Default is UIOption.OnlyErrorDialogs.

Exceptions

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

sourceDirectoryName or destinationDirectoryName is Nothing or an empty string.

The directory does not exist.

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

The path exceeds the system-defined maximum length.

The operation is cyclic.

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.

The user does not have required permission.

Examples

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)

Remarks

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

See also

Applies to

.NET Framework 4.8.1 og aðrar útgáfur
Vara Útgáfur
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 5, 6, 7, 8, 9

MoveDirectory(String, String, Boolean)

Source:
FileSystemProxy.vb
Source:
FileSystemProxy.vb
Source:
FileSystemProxy.vb

Moves a directory from one location to another.

public void MoveDirectory (string sourceDirectoryName, string destinationDirectoryName, bool overwrite);

Parameters

sourceDirectoryName
String

Path of the directory to be moved.

destinationDirectoryName
String

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

overwrite
Boolean

True if existing directories should be overwritten; otherwise False. Default is False.

Exceptions

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

sourceDirectoryName or destinationDirectoryName is Nothing or an empty string.

The directory does not exist.

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

The path exceeds the system-defined maximum length.

The operation is cyclic.

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.

The user does not have required permission.

Examples

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)

Remarks

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

See also

Applies to

.NET Framework 4.8.1 og aðrar útgáfur
Vara Útgáfur
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 5, 6, 7, 8, 9

MoveDirectory(String, String, UIOption, UICancelOption)

Source:
FileSystemProxy.vb
Source:
FileSystemProxy.vb
Source:
FileSystemProxy.vb

Moves a directory from one location to another.

public void MoveDirectory (string sourceDirectoryName, string destinationDirectoryName, Microsoft.VisualBasic.FileIO.UIOption showUI, Microsoft.VisualBasic.FileIO.UICancelOption onUserCancel);

Parameters

sourceDirectoryName
String

Path of the directory to be moved.

destinationDirectoryName
String

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

showUI
UIOption

Specifies whether to visually track the operation's progress. Default is UIOption.OnlyErrorDialogs.

onUserCancel
UICancelOption

Specifies whether or not an exception is thrown when the user cancels the operation. Default is UICancelOption.ThrowException.

Exceptions

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

sourceDirectoryName or destinationDirectoryName is Nothing or an empty string.

The directory does not exist.

onUserCancel is set to ThrowException and a subdirectory of the file cannot be copied.

onUserCancel is set to ThrowException, and the user cancels the operation, or the operation cannot be completed.

The user lacks necessary permissions to view the path.

The path exceeds the system-defined maximum length.

The operation is cyclic.

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

The user does not have required permission.

Examples

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)

Remarks

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

See also

Applies to

.NET Framework 4.8.1 og aðrar útgáfur
Vara Útgáfur
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 5, 6, 7, 8, 9