Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Long File Names
Message
 
To
15/11/2002 12:26:48
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00723279
Message ID:
00723303
Views:
14
OK - I now finally read full message. I personally do not use COPY FILE to copy multiple files (i.e. with *.*).

From code I downloaded from this forum, I've created a copy folder procedure that will copy the contents of one folder to another, including sub-folders. I use the CLSHEAP class that I got from here. One benefit I get from this (my reason for using it) is I get the copy animation dialog box, with progress bar).

Hope this helps,
James

--------------------------------------------------------------------------------------
#Include FoxPro.h
**********************************************************************
PROCEDURE Folder_Copy
**********************************************************************
* this procedure will copy a folder's contents to a new folder
* this copies the CONTENTS not the folder itself
* first parameter = source folder name, character
* second parameter = target folder name, character
* third parameter (optional) = include sub-folders, logical - default = .F.
**********************************************************************
    #DEFINE MB_TITLE "Folder_Copy"
    LPARAMETER tcSource, tcTarget, tlSubfolders

    LOCAL lcSource, lcTarget, loHeap, lnHeap, lnOptions, lcFileOpStruct, lnResult

    IF VARTYPE(tcSource) # "C"
        tcSource = SPACE(0)
    ENDIF
    IF VARTYPE(tcTarget) # "C"
        tcTarget = SPACE(0)
    ENDIF
    IF VARTYPE(tlSubfolders) # "L"
        tlSubfolders = .F.
    ENDIF
    IF EMPTY(tcSource) OR EMPTY(tcTarget)
        =MESSAGEBOX("Both source and target folders are required!", ;
                    MB_OK+MB_ICONSTOP,MB_TITLE)
        RETURN
    ENDIF
    IF !DIRECTORY(tcSource)
        =MESSAGEBOX("Source folder (" + tcSource + ") was not found!", ;
                    MB_OK+MB_ICONSTOP,MB_TITLE)
        RETURN
    ENDIF
    * target folder does not have to exist
    lcSource = tcSource
    lcTarget = tcTarget
    IF RIGHT(lcTarget,1) = "\"
        lcTarget  = LEFT(lcTarget,LEN(lcTarget)-1)
    ENDIF
    lcSource = ADDBS(lcSource)+ "*.*" + CHR(0) + CHR(0)
    lcTarget = lcTarget + CHR(0) + CHR(0)
    *
    DECLARE INTEGER SHFileOperation IN SHELL32.DLL STRING @ LPSHFILEOPSTRUCT
    DECLARE INTEGER GetActiveWindow IN WIN32API
    IF "CLSHEAP" $ UPPER(SET("PROCEDURE"))
        SET PROCEDURE TO CLSHEAP ADDITIVE
    ENDIF
    loHeap = CREATEOBJ('Heap')
    lnHeap = loHeap.AllocBlob(lcSource+lcTarget)
    lnOptions = FOF_NOCONFIRMATION + FOF_NOCONFIRMMKDIR
    IF !tlSubfolders
        lnOptions = lnOptions + FOF_FILESONLY
    ENDIF
    lcFileOpStruct = NumToDWORD(GetActiveWindow()) + ;
        NumToDWORD(FO_COPY) + ;
        NumToDWORD(lnHeap) + ;
        NumToDWORD(lnHeap + LEN(lcSource)) + ;
        NumToDWORD(lnOptions) + ;
        CHR(0) + ;
        NumToDWORD(0) + ;
        NumToDWORD(0)
    lnResult = SHFileOperation(lcFileOpStruct)
    IF lnResult # 0
        =MESSAGEBOX("There was a problem copying the folder's files.  Result code (" ;
            + TRANSFORM(lnResult) + ").", MB_OK+MB_ICONEXCLAMATION,MB_TITLE)
    ENDIF
    loHeap = .NULL.
    #Undefine MB_TITLE
ENDPROC
--------------------------------------------------------------------------------------
=======================
J Robert Jernigan
Calabasas, CA USA
jrjernigan@hotmail.com

"To err is human ... I should know, I get to show my humanity everyday!" jrj

"I just love the internet - it takes this great big planet and makes it smaller. Now, why can't we all just get along?" jrj
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform