请教怎样把一个目录下的所有文件复制到另一个目录下。不要用api函数

解决方案 »

  1.   

    Private Sub cmdCopy_Click()
        File1.Path = "d:\aa"  '假如要复制D盘AA目录下的所有文件
        
        For i = 0 To File1.ListCount - 1
            '假如将D盘AA目录下的所有文件复制到D盘BB目录下
            FileCopy File1.Path & "\" & File1.List(i), "d:\bb\" & File1.List(i)
        Next
    End Sub
      

  2.   

    Dim OFSO As New Scripting.FileSystemObject
    Dim ObjFile As Scripting.File
    Private Sub FileCopy(ByVal strSource As String, ByVal strdestin As String)
          If Right(strSource, 1) <> "\" Then strSource = strSource & "\"
          If Right(strdestin, 1) <> "\" Then strdestin = strdestin & "\"
          For Each ObjFile In OFSO.GetFolder(strSource).Files
                If OFSO.FileExists(strdestin & ObjFile.Name) Then
                    OFSO.Delete Filestrdestin & ObjFile.Name
                End If
                OFSO.CopyFile strSource & ObjFile, strdestin
          Next
    End Sub
      

  3.   

    cuizm(射天狼) 你好能否不用file控件,即纯粹的后台操作
      

  4.   

    dreamreality(追梦)  你好运行你的代码,系统提示此句
    Dim OFSO As New Scripting.FileSystemObject编译错误:
       用户定义类型未定义
      
      

  5.   

    “工程”->“引用”,选中“microsoft scripting runtime”
      

  6.   

    标准方法(只用内部功能)s=strsource
    s0=strtag
    s1=dir(s & "\*.*")
    do while s1<>""
        if left(s1,1)<>"." then
            filecopy s & "\" & s1 , s0 & "\" & s1
        endif
        s1=dir
    loop
      

  7.   

    dreamreality(追梦)  用的是外部控件,还不如用FILE内部控件呢!