예제 #1
0
        public static async Task <string> LocalCopy(UploadTask task, string sourceFileName, bool doNotCheckOverwrite = false)
        {
            var name       = Path.GetFileName(sourceFileName);
            var targetPath = task.LocalBackupPath + Path.DirectorySeparatorChar + name;
            var overwrite  = doNotCheckOverwrite || task.OverwriteAll;

            if (File.Exists(targetPath) && !overwrite)
            {
                if (MessageBox.Show($"File {name} exists in target directory {task.LocalBackupPath}. Are you sure you want to overwrite it?", "Overwrite?", MessageBoxButton.YesNo) == MessageBoxResult.No)
                {
                    throw new ServiceFailureException();
                }
                else
                {
                    overwrite = true;
                }
            }

            await IOHelpers.CopyFileAsync(sourceFileName, targetPath, overwrite);

            return(targetPath);
        }