I'm creating a very big file using a FileStream
(0.1 - 100 GBytes):
using (var strm = File.OpenWrite(Destination)) {
while(someCondition) {
bfr = GetBuffer();
strm.Write(bfr.Data, 0, ChunkSizeInBytes);
strm.Flush();
ShowProgress();
}
}
When I get to the end of the using
statement, the thread hangs for a long time. I put a strm.Close()
after the loop, and it seems that this is the jamming point (the file closure).
(please note that I Flush()
after each Write()
)
Why is it and how to overcome it ?