Name 语句

重命名现有文件或目录。

语法:

Name OldName As String As NewName As String

参数:

OldName、NewName:任意字符串表达式,都可以用于指定文件名,包括路径。也可以使用 URL 表示法

示例:

Sub ExampleReName

On Error GoTo Error

FileCopy "c:\autoexec.bat", "c:\temp\autoexec.sav"

Name "c:\temp\autoexec.sav" As "c:\temp\autoexec.bat"

End

Error:

If err = 58 Then

    MsgBox "文件已存在"

End If

End

End Sub