Sample code for 30+ languages & platforms
Rust

Split File into Chunks

Demonstrates how to split a file into chunks.

Chilkat Rust Downloads

Rust

let fac = chilkat::FileAccess::new();

// Any type of file may be split.  It doesn't matter if it's
// a binary file or a text file.
let file_to_split = "qa_data/hamlet.xml".to_string();

let part_prefix = "hamlet".to_string();
let part_extension = "part".to_string();
let max_chunk_size = 50000;
let dest_dir_path = "qa_output".to_string();

// 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.

if fac.split_file(&file_to_split, &part_prefix, &part_extension, max_chunk_size, &dest_dir_path).is_ok() {
    println!("Success.");
} else {
    println!("{}", fac.last_error_text());
}