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 copy MULTIPLE FILES to MULTIPLE DESTINATIONS with shFileOp?

    How is it done?
    I´ve seperated the Sources and Dests with a vbNullChar, however only the first destination is used so all my files end up in the same directory.
    Anyone?

    Grzzz,

    Braniac.


  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: How to copy MULTIPLE FILES to MULTIPLE DESTINATIONS with shFileOp?


    'If you're using winnt,CopyFileEx may be better. Change this to call it several
    ' times with source and destination changing each time.
    'warning: this will not work on win95/98/me
    'in a form (Form1)
    private Sub Form_Load()
    'KPD-Team 2001
    'URL: http://www.allapi.net/
    'E-Mail: [email protected]
    Dim Ret as Long
    'set the graphics mode to persistent
    me.AutoRedraw = true
    'print some text
    me.print "Click the form to abort the filecopy"
    'show the form
    me.Show
    'start copying
    Ret = CopyFileEx("c:\verybigfile.ext", "c:\copy.ext", AddressOf CopyProgressRoutine, byval 0&, bCancel, COPY_FILE_RESTARTABLE)
    'show some text
    me.print "Filecopy completed " + IIf(Ret = 0, "(error/ABORTED)", "successfully")
    End Sub
    private Sub Form_Click()
    'cancel filecopy
    bCancel = 1
    End Sub

    'in a module
    public Const PROGRESS_CANCEL = 1
    public Const PROGRESS_CONTINUE = 0
    public Const PROGRESS_QUIET = 3
    public Const PROGRESS_STOP = 2
    public Const COPY_FILE_FAIL_IF_EXISTS = &H1
    public Const COPY_FILE_RESTARTABLE = &H2
    public Declare Function CopyFileEx Lib "kernel32.dll" Alias "CopyFileExA" (byval lpExistingFileName as string, byval lpNewFileName as string, byval lpProgressRoutine as Long, lpData as Any, byref pbCancel as Long, byval dwCopyFlags as Long) as Long
    public bCancel as Long
    public Function CopyProgressRoutine(byval TotalFileSize as Currency, byval TotalBytesTransferred as Currency, byval StreamSize as Currency, byval StreamBytesTransferred as Currency, byval dwStreamNumber as Long, byval dwCallbackReason as Long, byval hSourceFile as Long, byval hDestinationFile as Long, byval lpData as Long) as Long
    'adjust the caption
    Form1.Caption = CStr(Int((TotalBytesTransferred * 10000) / (TotalFileSize * 10000) * 100)) + "% complete..."
    'allow user input
    DoEvents
    'continue filecopy
    CopyProgressRoutine = PROGRESS_CONTINUE
    End Function





    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Sep 2001
    Posts
    27

    Re: How to copy MULTIPLE FILES to MULTIPLE DESTINATIONS with shFileOp?

    Thanx, it looks very promising and I will try it.
    However, I´m developing my app in W98 and the final app will run on NT, so why wouldn't it work on 98 if i may ask?

    Grzzz, Braniac.


  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: How to copy MULTIPLE FILES to MULTIPLE DESTINATIONS with shFileOp?

    That Api should not exist (not supported) on win98...

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

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