CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2001
    Posts
    27

    How to DoEvents during a filecopy?

    Grzzz,

    I'm writing an application in which I have to copy a large amount of files over a slow network connection. I'm doing this through the shFileOp API, which looks nice.
    However, there seems to be no way to keep processing events during the copy process so my main form hangs for 20 minutes.

    Anyone know how to solve this?

    Thanx,

    Braniac.


  2. #2
    Join Date
    Aug 2000
    Location
    Ottawa, Canada
    Posts
    469

    Re: How to DoEvents during a filecopy?

    The only way is to put that copy task in separate thread.
    Unfortunately I have no experience of doing this in VB.


  3. #3
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: How to DoEvents during a filecopy?

    I wrote up a quick and dirty to test this and my app still processes events while the SHFileOperation function is running... click on button2 during a copy and msgbox shows...


    option Explicit
    private Type SHFILEOPSTRUCT
    hWnd as Long
    wFunc as Long
    pFrom as string
    pTo as string
    fFlags as Integer
    fAborted as Boolean
    hNameMaps as Long
    sProgress as string
    End Type
    private Const FO_DELETE = &H3
    private Const FO_COPY = &H2
    private Const FO_MOVE = &H1
    private Const FO_RENAME = &H4
    private Const FOF_ALLOWUNDO = &H40
    private Const FOF_FILESONLY = &H80
    private Const FOF_CONFIRMMOUSE = &H2
    private Const FOF_MULTIDESTFILES = &H1
    private Const FOF_NOCONFIRMATION = &H10
    private Const FOF_NOCONFIRMMKDIR = &H200
    private Const FOF_NOERRORUI = &H400
    private Const FOF_NORECURSION = &H1000
    private Const FOF_RENAMEONCOLLISION = &H8
    private Const FOF_SILENT = &H4
    private Const FOF_SIMPLEPROGRESS = &H100
    private Const FOF_WANTMAPPINGHANDLE = &H20
    private Const FOF_WANTNUKEWARNING = &H4000

    private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp as SHFILEOPSTRUCT) as Long

    private Sub Command1_Click()
    Dim FS as SHFILEOPSTRUCT
    FS.hWnd = me.hWnd
    FS.pFrom = "C:\somebigfile"
    FS.pTo = "C:\someotherfile"
    FS.wFunc = FO_COPY
    FS.fFlags = FOF_NOCONFIRMATION
    SHFileOperation FS
    End Sub

    private Sub Command2_Click()
    MsgBox "Hello"
    End Sub







  4. #4
    Join Date
    Sep 2001
    Posts
    27

    Re: How to DoEvents during a filecopy?

    You´re RIGHT!
    Maybe it´s because I had not implemented the filop yet, and was still using FileCopy instead!

    Thanx anyway!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured