C# webclient progresschanged downlodfileCompleted
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Net;
using System.IO;
using System.Windows.Forms; namespace ConsoleApp392
{
class Program
{
static void Main(string[] args)
{
WebClientDownloadDemo();
} static void WebClientDownloadDemo()
{
string url = "https://go.microsoft.com/fwlink/?linkid=866662";
WebClient webClient = new WebClient();
webClient.DownloadProgressChanged += WebClient_DownloadProgressChanged;
webClient.DownloadFileCompleted += WebClient_DownloadFileCompleted;
Console.WriteLine($"Started at {DateTime.Now.ToString("yyyyMMddHHmmssffff")}");
webClient.DownloadFileAsync(new Uri(url), "SSMS2019.exe");
} private static void WebClient_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
MessageBox.Show("Download Completed!");
} private static void WebClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
Debug.WriteLine($"{e.UserState?.ToString()} downloaded {e.BytesReceived} of {e.TotalBytesToReceive} bytes. {e.ProgressPercentage} % complete...");
Console.WriteLine($"{e.UserState?.ToString()} downloaded {e.BytesReceived} of {e.TotalBytesToReceive} bytes. {e.ProgressPercentage} % complete...");
}
}
}
C# webclient progresschanged downlodfileCompleted的更多相关文章
- 跨域请求——WebClient通过get和post请求api
AJAX不可以实现跨域请求,经过特殊处理才行.一般后台可以通过WebClient实现跨域请求~ //get 请求 string url = string.Format("htt ...
- C#通过WebClient/HttpWebRequest实现http的post/get方法
C#通过WebClient/HttpWebRequest实现http的post/get方法 http://www.cnblogs.com/shadowtale/p/3372735.html
- WebClient 实现多文件/文本同时上传
public class CreateBytes { Encoding encoding = Encoding.UTF8; /**/ /// <summary> /// 拼接所有的二进制数 ...
- WebClient 数据传输
数据提交 post ,get public string WebClientPost(string PostData, string PostUrl, string Type) { string p ...
- C# 文件下载 : WebClient
最近更新了一个下载小工具,主要提升了下面几点: 1. 在一些分公司的局域网中,连接不上外网 2. 服务器上的文件更新后,下载到的还是更新前的文件 3. 没有下载进度提示 4. 不能终止下载 下面和大家 ...
- C# 发送Http请求 - WebClient类
WebClient位于System.Net命名空间下,通过这个类可以方便的创建Http请求并获取返回内容. 一.用法1 - DownloadData string uri = "http:/ ...
- c# WebClient Get Post 方法
public string GetData(string url) { string data; using (var client = new WebClient()) { using (var s ...
- c# WebClient文件下载
public void HttpDownload(string url, string path, ResourceType type) { using (var client = new WebCl ...
- [解决WebClient或HttpWebRequest首次连接缓慢问题]
[编程环境]Visual Studio 2010, NET4.0 [开发语言]C#, 理论上VB.NET等依赖.NET Framework框架的语言均受此影响 [问题描述] 使用HttpWebRequ ...
随机推荐
- Django基础day01
后端(******) 软件开发结构c/s http协议的由来 sql语句的由来 统一接口统一规范 HTTP协议 1.四大特性 1.基于TCP/IP作用于应用层之上的协议 2.基于请求响应 3.无状态 ...
- springboot 集成jsp
建立好springboot项目,确定能成功运行 在application.properties文件中添加 server.context-path=/bootserver.port=8080spring ...
- VS2019 开发Django(七)------VS2019不能格式化html代码
如题,在VS2019中不能使用快捷键Ctrl+K,+D格式化html代码,印象中之前的版本是可以的吧!不太确定,这给我带来了很大的麻烦,在编写Django项目的时候,标准的模板是新建的html文件,不 ...
- Idea集成及使用svn插件
1 idea集成svn 1.1 svn是什么? SVN是subversion的缩写,是一个开放源代码的版本控制系统,通过采用分支管理系统的高效管理,简而言之就是用于多个人共同开发同一个项目,实现共享资 ...
- 如何在阿里云服务器上搭建wordpress个人网站
1.购买云服务器.域名.域名解析.配置linux系统上的web环境.FTP等参照下面的链接. https://www.cnblogs.com/smyhvae/p/4965163.html?tdsour ...
- docker 使用mysqldump命令备份导出项目中的mysql数据
下图为镜像重命名后的镜像名为uoj,现在要把这个镜像中的mysql导出 运行如下命令: docker exec -it uoj mysqldump -uroot -proot app_uoj233 & ...
- 代码管理平台之svn
yum install -y subversion(server和client均安装subversion) configure svn:[root@node01 ~]# mkdir -p /data/ ...
- Python活力练习Day1
Day1:输入年月日,判断这一天是这一年的第几天 eg: input : 2019-02-01 output : 32 data = list(input('please input ...
- 原创 Hive count 多个度量指标,带有 distinct
Hive count 多个度量指标,带有 distinct ,注意点!!! 比如 select organid, ppi, count(id1) as num1, count(distinct ...
- redis系列之------主从复制
什么是主从复制 Redis的主从复制机制是指可以让从服务器(slave)能精确复制主服务器(master)的数据,如下图所示: 或者 主从复制的方式和工作原理 工作方式: Redis主从复制主要 ...