Sample code for 30+ languages & platforms
Visual FoxPro

Split File into Chunks

Demonstrates how to split a file into chunks.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loFac
LOCAL lcFileToSplit
LOCAL lcPartPrefix
LOCAL lcPartExtension
LOCAL lnMaxChunkSize
LOCAL lcDestDirPath

lnSuccess = 0

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