Private Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Private Sub cmdOK_Click()
Dim Fso
Set Fso = CreateObject("Scripting.FileSystemObject")
If Fso.FileExists("D:\123\ABC.TXT") Then
MsgBox "文件已存在!"
Else
CopyFile "C:\ABC.TXT", "D:\123\ABC.TXT"
End If
用Dir函数判断是否存在那个文件,存在就不复制,不存在就复制
Private Sub Command1_Click()
If Dir("D:\123\ABC.TXT") = "" Then
FileCopy App.Path & "/ABC.TXT", "D:\123\ABC.TXT"
End If
End Sub