查看: 31  |  回复: 0
  VB6 文件拷贝子程序 f_FileCopy(strFN$, strFN2$)
楼主
发表于 2025年4月7日 15:36

新建From1(窗体),新建Command1(按钮CommandButton),代码:

Private Function f_FileCopy(strFN$, strFN2$) As Boolean
    If Dir(strFN2) = "" Then
        MsgBox "没找到 " & strFN2, vbCritical, "失败"
        f_FileCopy = False
        Exit Function
    End If
    
    If Dir(strFN) <> "" Then Kill strFN
    DoEvents
    FileCopy strFN2, strFN  '重命名
    f_FileCopy = True
End Function

Private Sub Command1_Click()
    Dim strFN$, strFN2$
    strFN = App.Path & "\abc.txt"
    strFN2 = strFN & ".bak"
    If f_FileCopy(strFN, strFN2) = False Then Exit Sub
    
    MsgBox "拷贝成功", vbInformation, "成功"
End Sub


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