Sample code for 30+ languages & platforms
B4X

Split File into Chunks

Demonstrates how to split a file into chunks.

Chilkat B4X Downloads

B4X
Dim success As Boolean = False

Dim fac As ChilkatFileAccess
fac.Initialize

'  Any type of file may be split.  It doesn't matter if it's
'  a binary file or a text file.
Dim fileToSplit As String = "qa_data/hamlet.xml"

Dim partPrefix As String = "hamlet"
Dim partExtension As String = "part"
Dim maxChunkSize As Int = 50000
Dim destDirPath As String = "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.
success = fac.SplitFile(fileToSplit, partPrefix, partExtension, maxChunkSize, destDirPath)

If success = True Then
    Log("Success.")
Else
    Log(fac.LastErrorText)
End If