Redigera

Dela via


FileSystem.RenameDirectory(String, String) Method

Definition

Renames a directory.

public:
 static void RenameDirectory(System::String ^ directory, System::String ^ newName);
public static void RenameDirectory (string directory, string newName);
static member RenameDirectory : string * string -> unit
Public Shared Sub RenameDirectory (directory As String, newName As String)

Parameters

directory
String

Path and name of directory to be renamed.

newName
String

New name for directory.

Exceptions

newName contains path information.

directory is Nothing.

-or-

newName is Nothing or an empty string.

The directory does not exist.

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

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.

The user does not have required permission.

Examples

This example renames the Test directory to SecondTest.

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

Remarks

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

Applies to

See also