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.RenameDirectory Method

Renames a directory.

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

public void RenameDirectory(
	string directory,
	string newName
)

Parameters

directory
Type: System.String

Path and name of directory to be renamed.

newName
Type: System.String

New name for directory.

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

ArgumentException

newName contains path information.

ArgumentNullException

directory is Nothing.

-or-

newName is Nothing or an empty string.

DirectoryNotFoundException

The directory does not exist.

IOException

There is an existing file or directory with the name specified in newName.

PathTooLongException

The path exceeds 248 characters.

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.

This method cannot be used to move a directory; use the MoveDirectory method to move and rename the directory.

This example renames the Test directory to SecondTest.

My.Computer.FileSystem.RenameDirectory("C:MyDocuments\Test", "SecondTest")

.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