Last active
March 3, 2017 15:22
-
-
Save Ganeshcse/431d739b9de445423adb2aa8667a3113 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Task.Run(() => | |
{ | |
isDirectoryCopySuccessful = CopyHelper.CopyDirectory(sourceLocation, destinationLocation); | |
Win.Application.Current.Dispatcher.Invoke(() => | |
{ | |
BaseWindow.HideNotification(); | |
ShowMessage?.Invoke("Files copied into destination location successfully", "Information"); | |
}); | |
}).ContinueWith((t) => | |
{ | |
if(t.IsFaulted) | |
{ | |
throw t.Exception; | |
} | |
else | |
{ | |
if (isDirectoryCopySuccessful) | |
{ | |
var description = "Copied To : " + selectedItem.GetFolderServerRelativeUrl(); | |
CopyHelper.InsertAuditLog( | |
sourceLocation, | |
selectedItem.GetFolderServerRelativeUrl(), | |
selectedItem.GetSiteUrl(), | |
description, | |
emailId, | |
userFullName); | |
} | |
} | |
}, TaskScheduler.FromCurrentSynchronizationContext()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach (var file in files) | |
{ | |
var fileInfo = new FileInfo(file); | |
CopyFile(fileInfo, destinationLocation); | |
currentProgressValue += 1; | |
//Dispatcher.CurrentDispatcher.Invoke(() => { | |
// BaseWindow.UpdateProgress(currentProgressValue, "Copying..."); | |
//}); | |
Win.Application.Current.Dispatcher.Invoke(() => | |
{ | |
BaseWindow.UpdateProgress(currentProgressValue, "Copying..."); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Win.Application.Current.Dispatcher.Invoke(() => | |
{ | |
canOverWriteFile = (bool)GetOverWriteConfirmation? | |
.Invoke("A file name already exists in the destination location? Do you want to overwrite it?", | |
"Confirmation", "Yes"); | |
}); | |
//canOverWriteFile = (bool)GetOverWriteConfirmation? | |
// .Invoke("A file name already exists in the destination location? Do you want to overwrite it?", | |
// "Confirmation", "Yes"); | |
if (!canOverWriteFile) | |
{ | |
// Log message with oldfile and new file name | |
var oldFileName = fullPath.Replace(destinationLocation + "\\", ""); | |
fullPath = GetFinalFileNameWithPath(fullPath); | |
string newName = fullPath.Replace(destinationLocation + "\\", ""); | |
var logMessgeBuilder = new StringBuilder(); | |
logMessgeBuilder.Append("Due to exsistance of another copy, File Name has been changed from"); | |
logMessgeBuilder.Append("" + oldFileName + " to " + newName + " on " + DateTime.Now.ToShortDateString() + ""); | |
// Log message that file name has been changed from old file to new file. | |
LogHelper.Info(logMessgeBuilder.ToString()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Exception I got is below,
Unknown error: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread.
Index was outside the bounds of the array.