Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copy Files using ShFileOperation
Message
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00727693
Message ID:
00727766
Views:
23
Thanks a lot, Sergey, I'll check, if this code would fix the problem. Can you post h file just in case?

Thanks.

>Here's the code I'm using
>
#INCLUDE SHFileOperation.h
>
>LPARAMETERS tcSource, tcDestination, tcAction, tlCanceled
>LOCAL lcSourceString, lcDestString, nStringBase, lcFileOpStruct, lnFlag, lnStringBase    , lcProgressTitle
>LOCAL oHeap, lcAction, lcActionText, lcOpt, lnRetCode
>
>DECLARE INTEGER SHFileOperation IN SHELL32.DLL STRING @ LPSHFILEOPSTRUCT
>SET PROCEDURE TO CLSHEAP ADDITIVE
>oHeap = CREATEOBJ('Heap')
>
>lcAction = UPPER(IIF( Empty( tcAction) Or VarType(tcAction) <> "C", "COPY", tcAction))
>
>DO CASE
>CASE lcAction = "COPY"
>	lcActionText = PROPER("COPY")
>	lnAction = FO_COPY
>CASE lcAction = "MOVE"
>	lcActionText = PROPER("MOVE")
>	lnAction = FO_MOVE
>CASE lcAction = "DELETE"
>	lcActionText = PROPER("DELETE")
>	lnAction = FO_DELETE
>CASE lcAction = "RENAME"
>	lcActionText = PROPER("RENAME")
>	lnAction = FO_RENAME
>OTHERWISE
>	RETURN Null
>ENDCASE
>
>lcOpt = ""
>
>lcSourceString = tcSource + CHR(0) + CHR(0)
>lcDestString   = tcDestination + CHR(0) + CHR(0)
>lnStringBase    = oHeap.AllocBlob(lcSourceString+lcDestString)
>lcProgressTitle = lcActionText  + " File '" + tcSource + "'" + "" + ;
>					IIF(lcAction="DELETE", "", " to '" + tcDestination + "'") + CHR(0)+ CHR(0)
>lnProgressTitle = oHeap.AllocBlob(lcProgressTitle)
>
>lnFlag = FOF_NOCONFIRMATION + FOF_NOCONFIRMMKDIR + FOF_NOERRORUI
>
>IF NOT ("*" $ tcSource OR "?" $ tcSource )
>	*lnFlag = lnFlag + FOF_SIMPLEPROGRESS
>ENDIF
>
>lcFileOpStruct  = NumToLONG(_screen.hWnd) + ;
>                NumToLONG(lnAction) + ;
>                NumToLONG(lnStringBase) + ;
>                NumToLONG(lnStringBase + LEN(lcSourceString)) + ;
>                NumToWORD(lnFlag) + ;
>                NumToLONG(0) + ;
>                NumToLONG(0) + ;
>                NumToLONG(lnProgressTitle )
>
>lnRetCode = SHFileOperation(@lcFileOpStruct)
>
>* Did user canceled operation?
>tlCanceled = ( SUBSTR(lcFileOpStruct, 19, 4) <> NumToLONG(0) )
>
>RETURN (lnRetCode = 0)
>
>>Hi everybody,
>>
>>I implemented copy files using a FAQ by Ed Rauh. I guess, I'm doing something wrong, because I'm getting an error on
>>=RtlCopyLong(@cString, BITOR(tnNum,0), 4) line. tnNum is undefined at this point.
>>
>>Here is my code:
>>
>>
>>lcFile = forceext(alltrim(.list(m.lnI,1)),"*")
>>     				if CopyFiles(m.dir_Download+ m.lcFile, ;
>>     				  m.dir_Lookups+ m.lcFile,'Copy')
>>     				  erase (m.dir_Download+ m.lcFile)
>>     				endif
>>
>>where m.dir_Download = "G:\REDP\Appl\DataEntry\Data\Download\"
>>m.dir_Lookups = "G:\REDP\Appl\DataEntry\Data\Lookups\"
>>
>>and lcFile = ISSUE.*
>>
>>When I tried it with Move parameter, it returned can not create Issue folder (weird). I'm trying with "Copy" and it gives me this error.
>>
>>Could you please help?
>>
>>Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform