예제 #1
0
        protected override void EndProcessing()
        {
            if (filesToCopy != null)
            {
                if (!PassThru)
                {
                    Host.UI.RawUI.PushHostUI();
                }

                foreach (var item in CopyFilesUtility.CopyFiles(Source, Destination, filesToCopy, Fast, Overwrite))
                {
                    if (!string.IsNullOrEmpty(item.ErrorMessage))
                    {
                        WriteVerbose(item.ErrorMessage);
                    }

                    if (PassThru)
                    {
                        WriteObject(item);
                    }
                    else
                    {
                        Host.UI.RawUI.ShowInformation("Copying files", item.Source);
                    }
                }

                if (!PassThru)
                {
                    Host.UI.RawUI.PopHostUI();
                }
            }
        }
예제 #2
0
        protected override void EndProcessing()
        {
            if (FoldersToCopy.Count() != 0)
            {
                foreach (string dir in FoldersToCopy)
                {
                    if (!PassThru)
                    {
                        Host.UI.RawUI.ShowInformation("Copying directories", dir);
                    }
                    if (Directory.Exists(dir))
                    {
                        try
                        {
                            var destDir = dir.Replace(Source, Destination);
                            CopyDirectoriesUtility.DirectoryCopy(dir, destDir);
                        }
                        catch (Exception ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                    }
                }
            }

            if (FoldersToRemove.Count() != 0)
            {
                foreach (string dir in FoldersToRemove)
                {
                    if (!PassThru)
                    {
                        Host.UI.RawUI.ShowInformation("Removing directories", dir);
                    }
                    if (Directory.Exists(dir))
                    {
                        try
                        {
                            Directory.Delete(dir, true);
                        }
                        catch (UnauthorizedAccessException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                        catch (PathTooLongException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                        catch (ArgumentNullException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                        catch (ArgumentException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                        catch (DirectoryNotFoundException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                        catch (NotSupportedException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                        catch (IOException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                    }
                }
            }

            if (FilesToRemove.Count() != 0)
            {
                foreach (string file in FilesToRemove)
                {
                    if (!PassThru)
                    {
                        Host.UI.RawUI.ShowInformation("Removing files", file);
                    }
                    if (File.Exists(file))
                    {
                        try
                        {
                            File.Delete(file);
                        }
                        catch (UnauthorizedAccessException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                        catch (PathTooLongException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                        catch (ArgumentNullException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                        catch (ArgumentException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                        catch (DirectoryNotFoundException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                        catch (NotSupportedException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                        catch (IOException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                    }
                }
            }

            foreach (var item in CopyFilesUtility.CopyFiles(Source, Destination, FilesToCopy, Fast))
            {
                if (!string.IsNullOrEmpty(item.ErrorMessage))
                {
                    WriteVerbose(item.ErrorMessage);
                }

                if (PassThru)
                {
                    WriteObject(item);
                }
                else
                {
                    Host.UI.RawUI.ShowInformation("Copying files", item.Source);
                }
            }

            if (!PassThru)
            {
                Host.UI.RawUI.PopHostUI();
            }
        }
예제 #3
0
        protected override void EndProcessing()
        {
            if (filesToCopy != null)
            {
                if (!PassThru)
                {
                    Host.UI.RawUI.PushHostUI();
                }

                foreach (var item in CopyFilesUtility.CopyFiles(Source, Destination, filesToCopy, Fast, Overwrite))
                {
                    if (string.IsNullOrEmpty(item.ErrorMessage))
                    {
                        try
                        {
                            File.Delete(item.Source);
                        }
                        catch (ArgumentNullException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                        catch (ArgumentException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                        catch (DirectoryNotFoundException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                        catch (NotSupportedException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                        catch (PathTooLongException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                        catch (IOException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                        catch (UnauthorizedAccessException ex)
                        {
                            WriteVerbose(ex.Message);
                        }
                    }
                    else
                    {
                        WriteVerbose(item.ErrorMessage);
                    }

                    if (PassThru)
                    {
                        WriteObject(item);
                    }
                    else
                    {
                        Host.UI.RawUI.ShowInformation("Moving files", item.Source);
                    }
                }

                if (!PassThru)
                {
                    Host.UI.RawUI.PopHostUI();
                }
            }
        }