FileSystem.MoveDirectory FileSystem.MoveDirectory FileSystem.MoveDirectory FileSystem.MoveDirectory Method

Definition

Moves a directory from one location to another.

Overloads

MoveDirectory(String, String) MoveDirectory(String, String) MoveDirectory(String, String) MoveDirectory(String, String)

Moves a directory from one location to another.

MoveDirectory(String, String, UIOption) MoveDirectory(String, String, UIOption) MoveDirectory(String, String, UIOption) MoveDirectory(String, String, UIOption)

Moves a directory from one location to another.

MoveDirectory(String, String, Boolean) MoveDirectory(String, String, Boolean) MoveDirectory(String, String, Boolean) MoveDirectory(String, String, Boolean)

Moves a directory from one location to another.

MoveDirectory(String, String, UIOption, UICancelOption) MoveDirectory(String, String, UIOption, UICancelOption) MoveDirectory(String, String, UIOption, UICancelOption) MoveDirectory(String, String, UIOption, UICancelOption)

Moves a directory from one location to another.

MoveDirectory(String, String) MoveDirectory(String, String) MoveDirectory(String, String) MoveDirectory(String, String)

Moves a directory from one location to another.

public:
 static void MoveDirectory(System::String ^ sourceDirectoryName, System::String ^ destinationDirectoryName);
public static void MoveDirectory (string sourceDirectoryName, string destinationDirectoryName);
static member MoveDirectory : string * string -> unit
Public Shared Sub MoveDirectory (sourceDirectoryName As String, destinationDirectoryName As String)

Parameters

sourceDirectoryName
String String String String

Path of the directory to be moved.

destinationDirectoryName
String String String 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 source is a root directory or The source path and the target path are the same.

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.

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.

Security

FileIOPermission
Controls the ability to access files and folders. Associated enumeration: Unrestricted.

See also

MoveDirectory(String, String, UIOption) MoveDirectory(String, String, UIOption) MoveDirectory(String, String, UIOption) MoveDirectory(String, String, UIOption)

Moves a directory from one location to another.

public:
 static void MoveDirectory(System::String ^ sourceDirectoryName, System::String ^ destinationDirectoryName, Microsoft::VisualBasic::FileIO::UIOption showUI);
public static void MoveDirectory (string sourceDirectoryName, string destinationDirectoryName, Microsoft.VisualBasic.FileIO.UIOption showUI);
static member MoveDirectory : string * string * Microsoft.VisualBasic.FileIO.UIOption -> unit
Public Shared Sub MoveDirectory (sourceDirectoryName As String, destinationDirectoryName As String, showUI As UIOption)

Parameters

sourceDirectoryName
String String String String

Path of the directory to be moved.

destinationDirectoryName
String String String String

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

showUI
UIOption UIOption UIOption 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 target directory already exists and overwrite is set to False.

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.

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.

Security

FileIOPermission
Controls the ability to access files and folders. Associated enumeration: Unrestricted.

UIPermission
Controls the permissions related to user interfaces and the clipboard. Associated enumeration: SafeSubWindows.

See also

MoveDirectory(String, String, Boolean) MoveDirectory(String, String, Boolean) MoveDirectory(String, String, Boolean) MoveDirectory(String, String, Boolean)

Moves a directory from one location to another.

public:
 static void MoveDirectory(System::String ^ sourceDirectoryName, System::String ^ destinationDirectoryName, bool overwrite);
public static void MoveDirectory (string sourceDirectoryName, string destinationDirectoryName, bool overwrite);
static member MoveDirectory : string * string * bool -> unit
Public Shared Sub MoveDirectory (sourceDirectoryName As String, destinationDirectoryName As String, overwrite As Boolean)

Parameters

sourceDirectoryName
String String String String

Path of the directory to be moved.

destinationDirectoryName
String String String String

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

overwrite
Boolean Boolean Boolean 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 target directory already exists and overwrite is set to False.

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.

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.

Security

FileIOPermission
Controls the ability to access files and folders. Associated enumeration: Unrestricted.

See also

MoveDirectory(String, String, UIOption, UICancelOption) MoveDirectory(String, String, UIOption, UICancelOption) MoveDirectory(String, String, UIOption, UICancelOption) MoveDirectory(String, String, UIOption, UICancelOption)

Moves a directory from one location to another.

public:
 static void MoveDirectory(System::String ^ sourceDirectoryName, System::String ^ destinationDirectoryName, Microsoft::VisualBasic::FileIO::UIOption showUI, Microsoft::VisualBasic::FileIO::UICancelOption onUserCancel);
public static void MoveDirectory (string sourceDirectoryName, string destinationDirectoryName, Microsoft.VisualBasic.FileIO.UIOption showUI, Microsoft.VisualBasic.FileIO.UICancelOption onUserCancel);
static member MoveDirectory : string * string * Microsoft.VisualBasic.FileIO.UIOption * Microsoft.VisualBasic.FileIO.UICancelOption -> unit
Public Shared Sub MoveDirectory (sourceDirectoryName As String, destinationDirectoryName As String, showUI As UIOption, onUserCancel As UICancelOption)

Parameters

sourceDirectoryName
String String String String

Path of the directory to be moved.

destinationDirectoryName
String String String String

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

showUI
UIOption UIOption UIOption UIOption

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

onUserCancel
UICancelOption UICancelOption UICancelOption 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.

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.

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

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.

Security

FileIOPermission
Controls the ability to access files and folders. Associated enumeration: Unrestricted.

UIPermission
Controls the permissions related to user interfaces and the clipboard. Associated enumeration: SafeSubWindows.

See also

Applies to