Example #1
0
        /// <include file="Tools/.Docs/.ManifestUninstaller.xml" path="docs/method[@name='Install(string, ManifestComponents, bool)']/*"/>
        public static bool Uninstall(string AppDirectory, ManifestComponents Components, bool ThrowExceptions)
        {
            foreach (var Component in Components.Values)
            {
                var Path = PathService.CombinePath(AppDirectory, Component.FileName);

                try
                {
                    if (FileService.Exists(Path))
                    {
                        FileDeleter.Delete(Path);
                    }
                }
                catch
                {
                    if (ThrowExceptions)
                    {
                        throw;
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Example #2
0
        public static void Main(string[] args)
        {
            if (!args.Any())
            {
                UsageInformation.Print();
                return;
            }

            var fileName = args.FirstOrDefault();

            Console.WriteLine(Resources.ConfirmationLine, fileName);
            var keyInfo = Console.ReadKey();

            if (keyInfo.Key != ConsoleKey.Y && keyInfo.Key != ConsoleKey.Enter)
            {
                return;
            }

            if (!FileDeleter.Delete(fileName))
            {
                var lastError = Marshal.GetLastWin32Error();
                Console.WriteLine();
                Console.WriteLine($"Error: {new Win32Exception(lastError).Message}");
            }
            else
            {
                ProgressTracker.Instance.Stop();
            }
        }
Example #3
0
        public static void Main(string[] args)
        {
            var parsedArgs = CmdLineArgsParser.Parse(args);

            if (!args.Any() || string.IsNullOrEmpty(parsedArgs.FileName))
            {
                UsageInformation.Print();
                return;
            }

            //If silent mode is not specified
            if (!parsedArgs.SilentModeEnabled)
            {
                Console.WriteLine(Resources.ConfirmationLine, parsedArgs.FileName);
                var keyInfo = Console.ReadKey();
                if (keyInfo.Key != ConsoleKey.Y && keyInfo.Key != ConsoleKey.Enter)
                {
                    return;
                }
            }

            if (!FileDeleter.Delete(parsedArgs.FileName))
            {
                var lastError = Marshal.GetLastWin32Error();
                Console.WriteLine();
                Console.WriteLine($"Error: {new Win32Exception(lastError).Message}");
            }
            else
            {
                ProgressTracker.Instance.Stop();
            }
        }
        public void CanDeleteFile()
        {
            var deleter = new FileDeleter();
            MakeSureFileIsNotPresentThanCreateIt();

            deleter.Delete(new List<string> { FILE_TO_DELETE });

            Assert.IsFalse(File.Exists(FILE_TO_DELETE));
        }
Example #5
0
        public static void Main(string[] args)
        {
            ParsedCmdLineArgs parsedArgs;

            try
            {
                parsedArgs = CmdLineArgsParser.Parse(args);
            }
            catch (CmdLineArgsParser.InvalidCmdLineException e)
            {
                CmdLineArgsParser.PrintUsage(e);
                return;
            }

            try
            {
                // get the full path for confirmation
                string filename = FileDeleter.GetFullPath(parsedArgs.FileName);

                //If silent mode is not specified
                if (!parsedArgs.SilentModeEnabled)
                {
                    Console.WriteLine(Resources.ConfirmationLine, filename);
                    var keyInfo = Console.ReadKey();
                    if (keyInfo.Key != ConsoleKey.Y && keyInfo.Key != ConsoleKey.Enter)
                    {
                        return;
                    }
                }

                FileDeleter.Delete(filename, parsedArgs.BypassAcl);
            }
            catch (Exception e)
            {
                Console.WriteLine();

                if (parsedArgs.PrintStackTrace)
                {
                    Console.WriteLine($"Error: {e.ToString()}");
                }
                else
                {
                    Console.WriteLine($"Error: {e.Message}");
                }
            }
            finally
            {
                ProgressTracker.Instance.Stop();
            }
        }
Example #6
0
 public void Run(ITaskOutput output, NameValueCollection metaData)
 {
     _command.Delete(ex => new SitecoreInstallerLoggingService().Error <int>(ex));
 }