查看: 5  |  回复: 0
  VB6 重命名语句 Name oldFileName As newFileName
楼主
发表于 昨天 23:33
Private Sub RenameFileUsingName()
    Dim oldFileName As String
    Dim newFileName As String
    
    ' 设置要重命名的源文件和目标文件名
    oldFileName = "C:\path\to\your\oldfile.txt"
    newFileName = "C:\path\to\your
ewfile.txt"
    
    ' 使用 Name 语句重命名文件
    On Error GoTo ErrorHandler
    Name oldFileName As newFileName
    MsgBox "文件重命名成功!"
    Exit Sub

ErrorHandler:
    MsgBox "文件重命名失败: " & Err.Description
End Sub


您需要登录后才可以回帖 登录 | 立即注册
【本版规则】请勿发表违反国家法律的内容,否则会被冻结账号和删贴。
用户名: 立即注册
密码:
2020-2025 MaNongKu.com