コード例 #1
0
        private string BuildFullName(string destPath, File file)
        {
            //split the unix like name that comes from TC
            string[] pathParts = file.Name.Split('/');

            //join them back using the proper separator for the environment
            string properPath = string.Join(Path.DirectorySeparatorChar.ToString(), pathParts);

            return(_fileSystem.CombinePath(destPath, properPath));
        }
コード例 #2
0
        private async Task Download(string destPath, File file)
        {
            var destFileName = BuildFullName(destPath, file);

            Log.Debug("Downloading: {0}", destFileName);

            _fileSystem.EnsureDirectoryExists(destFileName);
            Settings settings = new Settings();

            settings.Load();

            var http = new HttpClientWrapper(settings.TeamCityUri, settings.TeamCityUsername, settings.TeamCityPassword);

            using (Stream stream = await http.GetStream(file.ContentHref))
            {
                using (var fileStream = new FileStream(destFileName, FileMode.Create))
                {
                    await stream.CopyToAsync(fileStream);
                }
            }
        }