xHarbour Reference Documentation > Function Reference |
Copies files normally or in backup mode.
FileCopy( <cSourceFile>, ; <cTargetFile>, ; [<lBackup>] ) --> nBytesCopied
The funtion returns the number of bytes copied from <cSourceFile> to <cTargetFile>.
The FileCopy() function copies a source file to a target file. The <lBackup> parameter can be used to copy large files to several diskettes. If <lBackup> set to .T. (true), FileCopy() copies the maximum possible number of bytes to the target file (diskette). The function FileCOpen() is then used to check if <cSourceFile> is still open. If this is the case the user can be prompted to insert a new diskette and FileCCont() continues the copying operation.
Note: when a large file is copied to multiple diskettes, it can be re-assembled using the FileAppend() function.
See also: | CSetSafety(), FileAppend(), FileCClose(), FileCCont() |
Category: | CT:DiskUtil , File functions , Low level file functions |
Source: | ct\fcopy.prg |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example demonstrates the two modes of FileCopy() PROCEDURE Main LOCAL cSourceFile := "LargeFile.txt" LOCAL cTargetFile := "NewLargeFile.txt" LOCAL nCounter := 1 CLS ? "Regular copy " ?? FileCopy( cSourceFile, cTargetFile ), "bytes" ? "Backup copy " cTargetFile := "A:\backup.001" ?? cTargetFile, FileCopy( cSourceFile, cTargetFile ), "bytes" DO WHILE FileCOpen() WAIT "Please insert a new diskette in drive A:" nCounter ++ cTargetFile := "A:\backup." + StrZero( nCounter, 3 ) ? cTargetFile, FileCCont( cTargetFile ), "bytes" ENDDO RETURN
http://www.xHarbour.com