DataFlex
DataFlex
Split File into Chunks
Demonstrates how to split a file into chunks.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoFac
String sFileToSplit
String sPartPrefix
String sPartExtension
Integer iMaxChunkSize
String sDestDirPath
String sTemp1
Move False To iSuccess
Get Create (RefClass(cComCkFileAccess)) To hoFac
If (Not(IsComObjectCreated(hoFac))) Begin
Send CreateComObject of hoFac
End
// Any type of file may be split. It doesn't matter if it's
// a binary file or a text file.
Move "qa_data/hamlet.xml" To sFileToSplit
Move "hamlet" To sPartPrefix
Move "part" To sPartExtension
Move 50000 To iMaxChunkSize
Move "qa_output" To sDestDirPath
// 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.
Get ComSplitFile Of hoFac sFileToSplit sPartPrefix sPartExtension iMaxChunkSize sDestDirPath To iSuccess
If (iSuccess = True) Begin
Showln "Success."
End
Else Begin
Get ComLastErrorText Of hoFac To sTemp1
Showln sTemp1
End
End_Procedure