Xbase++
Xbase++
Split File into Chunks
Demonstrates how to split a file into chunks.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oFac
LOCAL cFileToSplit
LOCAL cPartPrefix
LOCAL cPartExtension
LOCAL nMaxChunkSize
LOCAL cDestDirPath
nSuccess := 0
oFac := CreateObject("Chilkat.FileAccess")
// Any type of file may be split. It doesn't matter if it's
// a binary file or a text file.
cFileToSplit := "qa_data/hamlet.xml"
cPartPrefix := "hamlet"
cPartExtension := "part"
nMaxChunkSize := 50000
cDestDirPath := "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.
nSuccess := oFac:SplitFile(cFileToSplit, cPartPrefix, cPartExtension, nMaxChunkSize, cDestDirPath)
IF (nSuccess == 1)
? "Success."
ELSE
? oFac:LastErrorText
ENDIF
oFac:destroy()