public override void Remove()
        {
            if (TargetFileSystem.FileExists(PathToConfig))
            {
                TargetFileSystem.DeleteFile(PathToConfig);
            }

            if (TargetFileSystem.DirectoryExists(InstallationPath) &&
                !string.Equals(LocalFileSystem.GetFullPath(BaselineSourcePath), TargetFileSystem.GetFullPath(InstallationPath), StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    TargetFileSystem.DeleteDirectory(InstallationPath);
                }
                catch (UnauthorizedAccessException)
                {
                    foreach (System.Diagnostics.Process p in Win32ProcessHelper.GetProcessesLockingFile(GetUnremovedFile(InstallationPath)))
                    {
                        Console.WriteLine("File is locked by Process(ID: {0}, NAME: {1}). Killing the process to unlock files", p.Id, p.ProcessName);
                        if (!p.WaitForExit(1000))
                        {
                            Win32ProcessHelper.TerminateProcess(p);
                            p.WaitForExit(5000);
                        }
                    }

                    TargetFileSystem.DeleteDirectory(InstallationPath);
                }
            }
        }
Пример #2
0
        public override void Remove()
        {
            base.Remove();

            if (TargetFileSystem.DirectoryExists(PathToVaultFolder))
            {
                TargetFileSystem.DeleteDirectory(PathToVaultFolder);
            }
        }