Exemplo n.º 1
0
        public override bool TryPrepareApplicationDirectory(out string error)
        {
            string upgradeApplicationDirectory = ProductUpgraderInfo.GetUpgradeApplicationDirectory();

            Exception deleteDirectoryException;

            if (this.FileSystem.DirectoryExists(upgradeApplicationDirectory) &&
                !this.FileSystem.TryDeleteDirectory(upgradeApplicationDirectory, out deleteDirectoryException))
            {
                error = $"Failed to delete {upgradeApplicationDirectory} - {deleteDirectoryException.Message}";

                this.TraceException(deleteDirectoryException, nameof(this.TryPrepareApplicationDirectory), $"Error deleting {upgradeApplicationDirectory}.");
                return(false);
            }

            if (!this.FileSystem.TryCreateOrUpdateDirectoryToAdminModifyPermissions(
                    this.Tracer,
                    upgradeApplicationDirectory,
                    out error))
            {
                return(false);
            }

            error = null;
            return(true);
        }