能实现么,有什么好的办法?

解决方案 »

  1.   

    dir 
    filecopy 就可以实现了
      

  2.   

    如上所说!
    你采用递归的方法,
    1)用DIR把该目录下需要COPY的文件一个个列出来,
    2)如果是目录就根据这个DIR得到的目录名加前面DIR时的路径,得到一个新的路径,转到1
    3)如果是文件,就做COPY的工作。
    4)DIR下一个文件或目录,注意,DIR(路径)返回的是一个文件夹名或文件名。
          再次DIR返回下一个文件夹名或文件名。
      

  3.   

    shell "copy c:\*.java c:\java\"
    然后用个文件列表控件判断一下就行了
      

  4.   

    引用Scripting对象
    对于文件的控制,我写了一个例子Option Explicit
    Dim ServerStr As String '''服务器上的相对路径
    Dim ClientStr As String '''本地想覆盖的文件名
    Dim FldServer As Scripting.Folder
    Dim FldClient As Scripting.Folder
    Dim Fso As New Scripting.FileSystemObject
    Dim Fil As Scripting.FilePrivate Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    Const SW_SHOW = 5Dim Mbwj As String
    Dim Mbwjmc As StringDim S As StringPrivate Sub Cmdsj_Click()
    On Error GoTo err
    Timer1.Interval = 200
    ServerStr = Trim(Command())'如果没有参数,提示后退出整个程序
    If ServerStr = "" Then
        S = MsgBox("请给定需要升级的参数!", vbInformation, "提示")
        End
    End IfSet FldServer = Fso.GetFolder("\\lxj\" & ServerStr)Set FldClient = Fso.GetFolder(App.Path & "\download\")''''把服务器上的文件复制到客户机的download目录下面
    For Each Fil In FldServer.Files
        Lbl.Caption = "正在升级文件" & Fil.Name
        DoEvents
        Call FileCopy(Fil.Path, FldClient.Path & "\" & Fil.Name)
    Next
    ''''文件复制完毕Timer1.Interval = 0
    '''开始进行文件的合并,合并的文件是个批处理文件
    '''得到生成的目标文件的名称For Each Fil In FldClient.Files
        '''如果是批处理文件则执行批处理文件
        Dim k As Integer
        If Right(Fil.Name, 3) = "bat" Then
            'Call Shell(Fil.Path, vbHide)  '''(FldClient.Path & Fil.Name)
            'ShellExecute Me.hwnd, "open", Fil.Name, "", "", SW_SHOW
            
            'Sleep (1000)
            Mbwj = Left(Fil.Path, Len(Fil.Path) - 4)
            Mbwjmc = Left(Fil.Name, Len(Fil.Name) - 4)
            Exit For
        End If
        
    '    If Right(Fil.Name, 3) = "000" Then
    '
    ''        Call Shell(Fil.Path, vbMaximizedFocus) '''(FldClient.Path & Fil.Name)
    ''        DoEvents
    '        Mbwj = Left(Fil.Path, Len(Fil.Path) - 4)
    '        Mbwjmc = Left(Fil.Name, Len(Fil.Name) - 4)
    ''       Exit For
    '    End If
    Next
    '''文件合并完毕
    jx:
    S = MsgBox("请运行download目录下的 " & Fil.Name & " 文件" & Chr(13) + Chr(10) & "然后点击 是 继续", vbInformation + vbYesNo, "提示")
    If S = vbYes Then
        Timer2.Interval = 2000
        Exit Sub
    End If
    err:
    S = MsgBox("升级失败", vbInformation, "错误")End SubPrivate Sub Timer1_Timer()
    Prb.Max = 100Prb.Min = 0Prb.Value = (CDbl(FldClient.Size) / CDbl(FldServer.Size)) * 100
    End SubPrivate Sub Timer2_Timer()
    'On Error GoTo err
    '''把生成的文件进行覆盖
    Call FileCopy(Mbwj, App.Path & "\" & Mbwjmc)
    '''''''''''''''''''''''
    '''删除download目录下面的所有文件
    For Each Fil In FldClient.Files
        Fil.Delete True
    NextS = MsgBox("文件升级成功!", vbInformation, "提示")
    End
    Timer2.Interval = 0
    Exit Suberr:
    Timer2.Interval = 0
    S = MsgBox("升级失败", vbInformation, "提示")
    End Sub