FileSystem.RenameDirectory(String, String) 方法
定义
重命名目录。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)
参数
- directory
- String
要重命名的目录的路径和名称。Path and name of directory to be renamed.
- newName
- String
目录的新名称。New name for directory.
例外
newName 包含路径信息。newName contains path information.
directory 为 Nothing。directory is Nothing.
- 或 --or-
newName 为 Nothing 或空字符串。newName is Nothing or an empty string.
该目录不存在。The directory does not exist.
存在一个具有 newName 中指定的名称的文件或目录。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.
示例
此示例将目录重命名 Test 为 SecondTest 。This example renames the Test directory to SecondTest.
My.Computer.FileSystem.RenameDirectory("C:MyDocuments\Test", "SecondTest")
注解
此方法不能用于移动目录;使用 MoveDirectory 方法移动和重命名目录。This method cannot be used to move a directory; use the MoveDirectory method to move and rename the directory.