Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SHFileOperation - copy without subdirectories?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01147760
Message ID:
01147766
Views:
29
This message has been marked as the solution to the initial question of the thread.
David,

Try to add
#DEFINE FOF_FILESONLY 0x0080  && on *.*, do only files
...
  NumToDWORD(FOF_NOCONFIRMATION + FOF_NOCONFIRMMKDIR + FOF_FILESONLY) + ;
>Using examples demonstrated on this site, I have set up a simple data backup utility utilizing SHFileOperation to copy files and all subdirectories. This is working wonderfully.
>
>There is one situation where I would like to copy all the files but not the subdirectories. I know how to do this using Copy Files, etc., but I am hoping to keep the same routine for both.
>
>Does SHFileOperation support copying all files wiithout copying the subdirectories? When I look at the syntax for SHFILEOPSTRUCT, I do not see any supported option for this. Am I missing something? My code follows:
>
>
>dfromdir = ALLTRIM(backup.fromdir)
>IF RIGHT(fromdir,1) <> '\'
>	dfromdir = dfromdir  + '\'
>ENDIF
>
>dtodir = ALLTRIM(backup.todir)
>IF RIGHT(todir,1) <> '\'
>	dtodir = dtodir + '\'
>ENDIF
>
>DECLARE INTEGER SHFileOperation IN SHELL32.DLL STRING @ LPSHFILEOPSTRUCT
>DECLARE INTEGER GetForegroundWindow IN WIN32API
>DECLARE INTEGER GetLastError IN WIN32API
>SET PROCEDURE TO CLSHEAP ADDITIVE
>oHeap = CREATEOBJ('Heap')
>#DEFINE FO_COPY 2
>#DEFINE FOF_NOCONFIRMATION 0x10    &&  Don't prompt the user.
>#DEFINE FOF_NOCONFIRMMKDIR 0x200   &&  don't confirm making any needed dirs
>
>cSourceString = dfromdir+'*.*' + CHR(0) + CHR(0)
>cDestString = dtodir + CHR(0) + CHR(0)
>
>cProgressTitle = CHR(0) + CHR(0)
>nStringBase = oHeap.AllocBlob(cSourceString+cDestString+cProgressTitle)
>cFileOpStruct = NumToDWORD(GetForegroundWindow()) + ;
>                NumToDWORD(FO_COPY) + ;
>                NumToDWORD(nStringBase) + ;
>                NumToDWORD(nStringBase + LEN(cSourceString)) + ;
>                NumToDWORD(FOF_NOCONFIRMATION + FOF_NOCONFIRMMKDIR) + ;
>                NumToDWORD(0) + ;
>                NumToDWORD(0) + ;
>                NumToDWORD(nStringBase + LEN(cSourceString)+LEN(cDestString))
>
>nResult = SHFileOperation(@cFileOpStruct) = 0
>IF nResult
>   *  It worked
>   *  Check for Aborts
>   IF DWORDToNum(SUBST(cFileOpStruct,21,4)) = 0
>      *  Something was aborted
>   ENDIF
>ELSE
>   *  Op failed - report result
>   =MESSAGEBOX('File Operation failed - ' + TRANSFORM(nResult,'@0'))
>ENDIF
>oHeap = ''
>
>
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform