I want to find a way to copy one file to multiple locations simultaneously (with C#).
means that i don't want the original file to be read only one time, and to "paste" the file to another locations (on local network).
as far as my tests showed me, the
File.Copy()
will always read the source again.
and as far as i understand, even while using memory, that memory piece gets locked.
so basically, i want to mimic the "copy-paste" to the form of one "copy", and multiple "paste", without re-reading from the Hard Drive again.
Why ? because eventually, i need to copy one folder (more than 1GB) to many computers, and the bottleneck is the part the i need to read the source file.
So, Is it even possible to achieve ?
Rather than using the
File.Copy
utility method, you could open the source file as aFileStream
, then open as manyFileStreams
to however many destination files you need, read from the source, and write to each destination stream.UPDATE Changed it to write files using Parallel.ForEach to improve throughput.
Usage: