private async Task <IScriptCommand> transferSystemIOAsync(ParameterDic pm, IEntryModel[] srcEntries, IEntryModel destEntry, string destinationKey) { return(await Task.Run <IScriptCommand>(async() => { var progress = pm.ContainsKey("Progress") ? pm["Progress"] as IProgress <TransferProgress> : NullTransferProgress.Instance; var srcProfile = srcEntries.First().Profile as IDiskProfile; var destProfile = destEntry.Profile as IDiskProfile; var srcMapper = srcProfile.DiskIO.Mapper; var destMapping = destProfile.DiskIO.Mapper[destEntry]; List <string> createdPath = new List <string>(); List <string> changedPath = new List <string>(); progress.Report(TransferProgress.IncrementTotalEntries(srcEntries.Count())); foreach (var srcEntry in srcEntries) { var srcMapping = srcMapper[srcEntry]; string destName = PathFE.GetFileName(srcMapping.IOPath); string destFullName = destProfile.Path.Combine(destEntry.FullPath, destName); progress.Report(TransferProgress.From(srcEntry.FullPath, destEntry.FullPath)); if (srcEntry.IsDirectory) { if (Directory.Exists(destFullName)) { changedPath.Add(destFullName); //Directory.Delete(destFullName, true); } else { createdPath.Add(destFullName); } Directory.Move(srcMapping.IOPath, destFullName); //Move directly. progress.Report(TransferProgress.IncrementProcessedEntries()); } else { if (File.Exists(destFullName)) { changedPath.Add(destFullName); File.Delete(destFullName); } else { createdPath.Add(destFullName); } File.Move(srcMapping.IOPath, destFullName); } progress.Report(TransferProgress.IncrementProcessedEntries()); } logger.Info(String.Format("{0} {1} -> {2} using System.IO", RemoveOriginal ? "Move" : "Copy", srcEntries.GetDescription(), destEntry.Name)); return await GetAssignDestinationCommandAsync(pm, srcEntries, destEntry, destinationKey, ScriptCommands.RunParallel(NextCommand, CoreScriptCommands.NotifyEntryChangedPath(ChangeType.Created, destEntry.Profile, createdPath.ToArray()), CoreScriptCommands.NotifyEntryChangedPath(ChangeType.Changed, destEntry.Profile, changedPath.ToArray()) )); })); }