(Visual FoxPro) Split File into Chunks
Demonstrates how to split a file into chunks.
LOCAL loFac
LOCAL lcFileToSplit
LOCAL lcPartPrefix
LOCAL lcPartExtension
LOCAL lnMaxChunkSize
LOCAL lcDestDirPath
LOCAL lnSuccess
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.FileAccess')
loFac = CreateObject('Chilkat.FileAccess')
* Any type of file may be split. It doesn't matter if it's
* a binary file or a text file.
lcFileToSplit = "qa_data/hamlet.xml"
lcPartPrefix = "hamlet"
lcPartExtension = "part"
lnMaxChunkSize = 50000
lcDestDirPath = "qa_output"
* Splits hamlet.xml into hamlet1.part, hamlet2.part, ...
* Output files are written to the current working directory.
* Each chunk will be 50000 bytes except for the last which
* will be the remainder.
lnSuccess = loFac.SplitFile(lcFileToSplit,lcPartPrefix,lcPartExtension,lnMaxChunkSize,lcDestDirPath)
IF (lnSuccess = 1) THEN
? "Success."
ELSE
? loFac.LastErrorText
ENDIF
RELEASE loFac
|