如果我想把一个.mdb文件备份到某个地方用CommonDialog1控件怎么实现啊
举个简单例子吧  谢谢

解决方案 »

  1.   

    Private Sub cmdOpenAccessFile_Click()
        CommonDialog11.Filter = "数据库文件(*.mdb)|*.mdb"
        CommonDialog1.DialogTitle = "请选择需打开的数据库文件"
        CommonDialog1.ShowOpen
        
        txtAccesFilePath.Text = cdOpenAccess.FileName
    End Sub
      

  2.   

    Copy文件的实现如下:Private Type SHFILEOPSTRUCT
         hWnd As Long
         wFunc As Long
         pFrom As String
         pTo As String
         fFlags As Integer
         fAnyOperationsAborted As Boolean
         hNameMappings As Long
         lpszProgressTitle As String
    End TypePrivate Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
    Private Const FO_COPY = &H2 '十进制2
    Private Const FOF_ALLOWUNDO = &H40 '十进制64Public Sub CopyFileWindowsWay(SourceFile As String, DestinationFile As String)
        Dim lngReturn As Long
        Dim typFileOperation As SHFILEOPSTRUCT
        With typFileOperation
        .hWnd = 0
        .wFunc = FO_COPY
        .pFrom = SourceFile & vbNullChar & vbNullChar '源文件
        .pTo = DestinationFile & vbNullChar & vbNullChar '目标文件
        .fFlags = FOF_ALLOWUNDO
        End With
        
        '拷贝操作
        lngReturn = SHFileOperation(typFileOperation)
        If lngReturn <> 0 Then '如果拷贝失败
            MsgBox Err.LastDllError, vbCritical Or vbOKOnly
        Else
            If typFileOperation.fAnyOperationsAborted = True Then
                MsgBox "Operation Failed", vbCritical Or vbOKOnly
            End If
        End If
        MsgBox "拷贝成功!", vbInformation, "提示"
    End SubPrivate Sub Command1_Click()
        '调用拷贝函数
        Call CopyFileWindowsWay(Text1.Text, Text2.Text)
    End SubPrivate Sub Command3_Click()
        Dim Counter As Integer
        Dim Workarea(5000) As String
         '返回一个 Long 型数据,其值为指定数组维可用的最小下标。
        ProgressBar.Min = LBound(Workarea)
        ProgressBar.Max = UBound(Workarea)
        ProgressBar.Visible = True
        
        '设置进度的值为 Min。
        ProgressBar.Value = ProgressBar.Min    '在整个数组中循环。
        'UBound 返回一个 Long 型数据,其值为指定的数组维可用的最大下标。
        For Counter = LBound(Workarea) To UBound(Workarea)
          '设置数组中每项的初始值。
          Workarea(Counter) = "Initial value" & Counter
          ProgressBar.Value = Counter
        Next Counter
        ProgressBar.Visible = False
        ProgressBar.Value = ProgressBar.Min
        
    End SubPrivate Sub Form_Load()
        Text1.Text = App.Path + "\example62.exe"
        Text2.Text = "c:\example62.exe"
        
        ProgressBar.Align = vbAlignBottom
        ProgressBar.Visible = False
        Command3.Caption = "初始化数组"End Sub
      

  3.   

    Dim fso
     Set fso = CreateObject("SCRIPTING.filesystemobject")
     If (fso.folderexists(App.Path & "\backup")) Then
     Else
     fso.createfolder App.Path & "\backup"
     End If
     If (fso.FileExists(DbAddress)) Then fso.Copyfile DbAddress, App.Path & "\backup\", True
     MsgBox "完成, "完成
     End If