.net - What is the fastest method to merge a number of files into a file in c#? -
i handle big files(of capacities minimum 500mb) split , merge c#.
i have split file thousands of files, sort these files groups, , merge these each group.
the minimum number of files 10,000.
i implement merge function using method stream.copyto(). here main part of that.
using (stream writer = file.openwrite(outputfilepath)) { int filenum = filepaths.count(); (int = 0; < filenum; i++) { using (stream reader = file.openread(filepaths.elementat(i))) { reader.copyto(writer); } } }
i've tested program split 500mb 17000 files of 2 groups , merge each group of 8500 files 1 file.
the merging part takes 80 seconds. think pretty slow compared splitting same file takes 15~20 seconds
is there method faster code?
your code looks fine elementat
code smell. convert array , use [i]
instead. if have 10k elements i'm positive you're wasting lot of time.
Comments
Post a Comment