<commit_before>﻿using System;
using System.ComponentModel;
using System.Net;

namespace dnget
{
    internal static class Program
    {
        private static void Main()
        {
            Console.WriteLine("Enter source url: ");
            string remoteUri = Console.ReadLine();
            Console.WriteLine("Enter file.name: ");
            string fileName = Console.ReadLine();
            WebClient myWebClient = new WebClient();
            Console.WriteLine($"\nDownloading File \"{fileName}\" to {Environment.CurrentDirectory}\nfrom \"{remoteUri}\"\n");
            myWebClient.DownloadFileCompleted += Completed;
            myWebClient.DownloadProgressChanged += ProgressChanged;
            myWebClient.DownloadFileAsync(new Uri(remoteUri), fileName);
            Console.ReadKey();
        }

        private static void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            Console.SetCursorPosition(0, Console.CursorTop);
            Console.Write($"\rDownloaded {BytesToString(e.BytesReceived)}    ");
            System.Threading.Thread.Sleep(1000);
        }

        private static void Completed(object sender, AsyncCompletedEventArgs e)
        {
            if (!e.Cancelled)
            {
                Console.WriteLine($"\nDownload task completed.");
            }
        }

        private static String BytesToString(long byteCount)
        {
            string[] suf = { "B", "KB", "MB", "GB", "TB", "PB", "EB" };
            if (byteCount == 0)
                return "0" + suf[0];
            long bytes = Math.Abs(byteCount);
            int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)));
            double num = Math.Round(bytes / Math.Pow(1024, place), 1);<commit_msg>Porgram: use HttpClient instead of WebClient<commit_after>﻿using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;

namespace dnget
{
    internal static class Program
    {
        private const int BufferSize = 256;
        
        private static void Main()
        {
            Console.WriteLine("Enter source url: ");
            string remoteUri = Console.ReadLine();
            Console.WriteLine("Enter file.name: ");
            string fileName = Console.ReadLine();
            Download(remoteUri, fileName).Wait();
        }

        private static async Task Download(string url, string fileName)
        {
            using (var client = new HttpClient()) {
                Console.WriteLine($"\nDownloading File \"{fileName}\" to {Environment.CurrentDirectory}\nfrom \"{url}\"\n");
                using (var fileStream = new FileStream(fileName, FileMode.Create))
                using (var stream = await client.GetStreamAsync(url))
                {
                    var buffer = new byte[BufferSize];
                    var read = 0;
                    while ((read = await stream.ReadAsync(buffer, 0, buffer.Length)) != 0)
                    {
                        await fileStream.WriteAsync(buffer, 0, read);
                        Console.Write($"\r{fileStream.Position} bytes read");
                        if ()
                    }
                }
                
                Console.WriteLine($"\nDownload completed");
            }
        }

        private static String BytesToString(long byteCount)
        {
            string[] suf = { "B", "KB", "MB", "GB", "TB", "PB", "EB" };
            if (byteCount == 0)
                return "0" + suf[0];
            long bytes = Math.Abs(byteCount);
            int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)));
            double num = Math.Round(bytes / Math.Pow(1024, place), 1);
{'fraction_non_alphanumeric': 0.11579233487360696, 'fraction_numerical': 0.010872519706441968, 'mean_word_length': 1.848297213622291, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2513828', 'n_tokens_mistral': 969, 'n_tokens_neox': 915, 'n_words': 229}