Exemplo n.º 1
0
        private async void HandleDownloadedFileAsync(object sender, DownloadedWebPageEventArgs e)
        {
            if (e == null || e.Uri == null)
            {
                return;
            }

            string filePath = GetLocalFilePath(e.Uri);

            Directory.CreateDirectory(filePath);

            filePath = Path.Combine(filePath, "index.html");

            await WriteFileAsync(filePath, e.Content);

            var args = new FileWriteEventArgs
            {
                FilePath = filePath,
            };

            OnFileWritten(args);
        }
Exemplo n.º 2
0
        private void HandleDownloadedPage(object sender, DownloadedWebPageEventArgs e)
        {
            Interlocked.Increment(ref counter);

            Console.WriteLine($"Downloaded page: {counter} - {e.Uri.AbsoluteUri}");
        }