现在我要把d:\下整个文件夹App(及文件夹中的文件)复制到c:\下,请问我怎么写程序。   谢谢

解决方案 »

  1.   

    Dim fso As New FileSystemObject
    fso.CopyFolder "d:\app\", "c:\"
    Set fso = Nothing
      

  2.   

    yoki:    不行啊,显示
       
                User-defined type not defined
      

  3.   

    试试Private Sub Command1_Click()
        Dim fs As Object
        Set fs = CreateObject("Scripting.FileSystemObject")
        fs.CopyFolder "d:\app\", "c:\"
    End Sub
      

  4.   

    用文件系统模型filesystemobject,CopyFolder方法
      

  5.   

    Dim fs 
        Set fs = CreateObject("Scripting.FileSystemObject")
        fs.CopyFolder "d:\app", "c:\"
      

  6.   

    Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
    Private Type SHFILEOPSTRUCT
            hwnd As Long
            wFunc As Long
            pFrom As String
            pTo As String
            fFlags As Integer
            fAnyOperationsAborted As Long
            hNameMappings As Long
            lpszProgressTitle As String '仅用于 FOF_SIMPLEPROGRESS
    End Type
    Private Const FO_COPY = &H2 '复制
    '复制文件
    Private Function CopyFile(ByVal sFileFrom As String, ByVal sFileTo As String) As BooleanDim fo As SHFILEOPSTRUCT
    With fo
      .pFrom = sFileFrom
      .pTo = sFileTo
      .wFunc = FO_COPY
    End With
    CopyFile = Not (CBool(SHFileOperation(fo)))
    End Function'调用时:
    Private Sub Command1_Click()
    Debug.Print CopyFile("f:\Music\she", "f:\a")
    End Sub