Function CopyDir
Lparameters SourcePath, TargetPath

*==============================================================================
*| Purpose...... Copies a directory with subfolders
*| Author....... Vaggelakos
*| Created...... June 05, 2006
*| About........
*| Mod List.....
*==============================================================================

Local CountOfFiles, OldPath, SourceFile, TargetName
Local Ret_Val, i

LOCAL array infodbf[1]

i = 0
Ret_val = .f.
IF VARTYPE(Targetpath)="C"  AND VARTYPE(SourcePath)="C"
 TargetPath = ADDBS(TargetPath)

 if len(Alltrim(SourcePath))>0 then
  IF DIRECTORY(SourcePath) then
   CountOfFiles = Adir(InfoDbf, SourcePath + "*.*","D")
   if CountOfFiles > 0 then
    For i = 1 to CountOfFiles
     thisform.prgbar1.update(i/CountOfFiles * 100)
     IF AT("D",InfoDbf(i,5))= 0 THEN
      *File Case
      SourceFile = SourcePath + infodbf(i,1)
      TargetName = TargetPath + infodbf(i,1)
      Copy FILE(SourceFile) to (TargetName)
     endif

     IF AT("D",InfoDbf(i,5))> 0 and AT(".",InfoDbf(i,1)) = 0
      *WAIT WINDOW "Hey huston Directory Inside!"
      lcFolder = TargetPath + InfoDbf(i,1)
      IF NOT DIRECTORY(lcFolder)
       MkDir &lcFolder
      ENDIF
          Copydir(ADDBS(SourcePath + InfoDbf(i,1)),lcFolder)
     ENDIF

     *thisform.prgbar1.update(i/CountOfFiles * 100)
    Next
    Ret_val = .t.
   endif
  ENDIF
 endif
endif

Return Ret_Val
EndFunc

************************************
Hope this Helps
Vassiis Aggelakos


----- Original Message ----- 
From: "George" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, March 01, 2007 7:24 PM
Subject: How to Copy (not move) Directory, Subdirectories and all files with
FoxPro


> Trying to Copy a Directory, all subdirectories and all files with VFP.
> I haven't found an API for this.
>
> Any suggestions will be greatly appreciated
>
> TIA
>
> George.
>
>
>
[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to