Private Sub cmdOut_Click()
CDialog.DialogTitle = "请输入巡更备份文件名"
CDialog.Filter = "巡更备份文件(*.XGB)|*.XGB"
CDialog.FilterIndex = 1
CDialog.InitDir = "c:\"
CDialog.Flags = cdlOFNHideReadOnly
CDialog.Filename = txtOut.Text
CDialog.ShowSave
txtOut.Text = CDialog.Filename
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''
'导出文件
If txtOut.Text = "" Then
MsgBox "请输入备份文件名!", vbExclamation, "提示"
Exit Sub
End If
If FileExists(txtOut.Text) Then
If MsgBox(txtOut.Text & "已经存在,是否要覆盖?", vbQuestion + vbYesNo, "提示") = vbNo Then Exit Sub
On Error GoTo out_err
Kill txtOut.Text
End If
BACKCnn.Close
FileCopy BACKDATABASE, txtOut.Text
If BACKCnn.State = adStateClosed Then BACKCnn.Open BackUpCnnString
MsgBox "备份文件导出成功!", vbExclamation, "提示"
Unload Me
Exit Sub
out_err:
MsgBox "备份文件导出错误!错误代码:" & vbCrLf & Error(Err), vbCritical, "错误"
If BACKCnn.State = adStateClosed Then BACKCnn.Open BackUpCnnString
Exit Sub
用FileCopy吧
假如正在使用您可以使用
FileSystemObject对象的CopyFile或者
API函数
Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Declare Function CopyFileEx Lib "kernel32.dll" Alias "CopyFileExA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal lpProgressRoutine As Long, lpData As Any, ByRef pbCancel As Long, ByVal dwCopyFlags As Long) As Long