private bool TryGetPreviousVersion(RelaseRequest request) { bool result = true; if (Directory.Exists(request.ReleasePath)) { Directory.Delete(request.ReleasePath, true); } Directory.CreateDirectory(request.ReleasePath); if (_distributor.FileExists(Extensions.RELEASE_INFO_FILENAME)) { "Previous version detected, getting new version...".WriteInfoToConsole(); string releaseFile = Path.Combine(request.ReleasePath, Extensions.RELEASE_INFO_FILENAME); _distributor.DownloadFile(Extensions.RELEASE_INFO_FILENAME, Path.Combine(request.ReleasePath, Extensions.RELEASE_INFO_FILENAME)); var lastVersionFile = File.ReadAllLines(releaseFile).Select(c => c.Split(' ')[1].Trim()).LastOrDefault(c => c.StartsWith(request.AppId)); if (_distributor.FileExists(lastVersionFile)) { _distributor.DownloadFile(lastVersionFile, Path.Combine(request.ReleasePath, lastVersionFile)); "Previous version downloaded".WriteSuccessToConsole(); } else { $"Previous version file {lastVersionFile} cannot be downloaded ".WriteErrorToConsole(); result = false; } } else { "No previous version detected".WriteInfoToConsole(); } return(result); }