Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var task1 = Task.Factory.StartNew(() =>
- {
- File.Copy(Path,NewName1, true);
- });
- var task2 = Task.Factory.StartNew(() =>
- {
- File.Copy(Path,NewName2, true);
- });
- public void ParallelCopy(string src, params string[] dsts)
- {
- Parallel.ForEach(dsts, new ParallelOptions(),
- dstOne =>
- {
- using (FileStream source = new FileStream(src, FileMode.Open, FileAccess.Read, FileShare.Read))
- using (FileStream destination = new FileStream(dstOne, FileMode.Create))
- {
- var buffer = new byte[4096];
- int read;
- while ((read = source.Read(buffer, 0, buffer.Length)) > 0)
- {
- destination.Write(buffer, 0, read);
- }
- }
- });
- }
- ParallelCopy(@"x:source.file", @"c:destination1.file", @"d:destination2.file");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement