The huge time and memory consuming part was the copying of the files with each substr routine. I could solve that now by using Memory Streams. Speed increased by several factors.