API Copy problem
Posted: Sun Feb 10, 2008 8:41 pm
I am having trouble understanding why this code keeps failing. It is a simple copy command using the windows API function. I like to use it because is as the progress bar and icon all in one. Here is the code. I can get it to work if I code the file path my self. You will see that it is remarked out now but if I use the other function to get the same path it will fail. I have checked and the name is the same. I am open for suggestions.
Code: Select all
Procedure.s Win_Spec_Loc(Valeur.l)
;Based on Droopy Library v1.31.4
;Modified to no have a \ at the end
If SHGetSpecialFolderLocation_(0, Valeur, @TR_ID) = 0
SpecialFolderLocation.s = Space(#MAX_PATH)
SHGetPathFromIDList_(TR_ID, @SpecialFolderLocation)
EndIf
ProcedureReturn SpecialFolderLocation.s
EndProcedure
Procedure.b CpyDir(FromLoc.s, Toloc.s)
Switches.SHFILEOPSTRUCT ;Windows API Structure
File_From.s = FromLoc
File_Dest.s = Toloc
Switches\wFunc = #FO_COPY
Switches\pFrom = @File_From
Switches\pTo = @File_Dest
Switches\fFlags = #FOF_NOCONFIRMATION | #FOF_NOCONFIRMMKDIR
Result.l = SHFileOperation_(@Switches)
; If cancel was pressed then result will NOT be zero (0)
EndProcedure
Procedure Main()
Dir_From.s =Win_Spec_Loc(6)
;Dir_From.s = "C:\Documents and Settings\Todd\Favorites"
Dir_To.s = "C:\Todd1234"
Error.b = CpyDir(Dir_From,Dir_To)
If Error =#False : A$= "Cancel" : End : Else : A$ = "Sucessful" :EndIf
EndProcedure
Main()