就是用shell命令复制图片文件到另一文件夹时,怎样判断图片是不是已经复制完毕(以便执行下一操作)?

解决方案 »

  1.   

    自己写复制的过程:
    '复制文件之前,先建立文件夹
    Private Sub MakeDir(FileName As String)
        Dim Str As String, i As Integer
        Dim TempC(255) As String    Str = FileName    If Left(Str, 1) = "\" Then
            Str = App.Path & Str
        Else
            'Str = App.Path & "\" & Str
        End If    Do
            If ExitMe = True Then Exit Sub: Exit Do
            If i = 0 Then
                TempC(i) = Left(Str, InStr(Str, "\") - 1)
            Else            TempC(i) = TempC(i - 1) & "\" & Left(Str, InStr(Str, "\") - 1)
                If Len(Dir(TempC(i) & "\", vbDirectory)) = 0 Then MkDir TempC(i)
            End If
            Str = Mid(Str, InStr(Str, "\") + 1)
            i = i + 1
        Loop Until InStr(Str, "\") = 0End Sub
    '复制文件,并显示进度条
    Private Sub CopyFiles(FileName As String, CopyTo As String)
        '如果存在镶套文件夹,则先建立文件夹
        On Error Resume Next
        Call MakeDir(CopyTo)    On Error Resume Next
        Dim FileStr()  As Byte, ReNew As Long, FileCounts As Long
        ReNew = 10485759  '2M 块
        ReDim FileStr(ReNew)    XP_Progress.Value = 0    If Trim(Dir(FileName)) = "" Then GoTo 10    Kill CopyTo                                       '先删除文件
        Open FileName For Binary Access Read As #1        '读取源文件。
        
        Open CopyTo For Binary Access Write As #2         '写入文件。    XP_Progress.Visible = True
        XP_Progress.Max = LOF(1) \ ReNew + 1    For FileCounts = 0 To LOF(1) \ ReNew - 1
            DoEvents
            If ExitMe = True Then Exit Sub:  Exit For
            XP_Progress.Value = FileCounts
            Get #1, FileCounts * ReNew + 1, FileStr
            Put #2, FileCounts * ReNew + 1, FileStr
            XP_Progress.Value = XP_Progress.Max
        Next
    10
        Dim w As Long    w = LOF(1) - (LOF(1) \ ReNew) * ReNew    ReDim FileStr(w - 1)
        Get #1, (LOF(1) \ ReNew) * ReNew + 1, FileStr
        Put #2, (LOF(1) \ ReNew) * ReNew + 1, FileStr
        XP_Progress.Value = FileCounts + 1    Close #2
        Close #1
        Erase FileStr
        XP_Progress.Visible = False
    End Sub
      

  2.   

    什么Shell命令?
    可以用WaitForSingleObject这个API等待一个程序得退出
      

  3.   

    shell命令????是不是要调用dos的copy命令来实现????调用copy命令系统中会多一个cmd.exe进程,你用带/c开关的cmd来调用copy命令,完成后cmd.exe会自动关闭,你就检测它关闭了就是文件复制完成了。
    不过觉得这问题有点小题大做。
      

  4.   

    哦,上面VirtualDesktop(吴滂:欢迎到我的Blog转转 ^_^)兄的WaitForSingleObject也行
      

  5.   

    刚用xcopy测试因为shell返回的只是是否成功调用这个程序,与是否执行完无关.
    所以要从xcopy来着手
    可以在进程是看到有xcopy.exe正在运行,
    可以检测是否有xcopy.exe正在运行来判断
    但问题是如果此时还有其它程序在执行copy,则,,,,就不知道怎么办了
    :)
    不知道能不能查看xcopy.exe的信息
      

  6.   

    shell返回的就是processid, 你openprocess一下可以得到handle。
    如果一个进程退出了, 那么他的handle就会变成active的,
    waitforsingleobject一个handle, 会一直组塞到这个handle变成了atcive。
      

  7.   

    我用的命令是
    Shell "cmd.exe /c copy " + FNAME + " " + App.Path + "\imagefile\", vbHide能不能给一个waitforsingleobject的例子?