WebClient client = new WebClient();

第一种

string URLAddress = @"http://files.cnblogs.com/x4646/tree.zip";

string receivePath=@"C:\";

client.DownloadFile(URLAddress, receivePath + System.IO.Path.GetFileName(URLAddress));

就OK了。

第二种

 Stream str = client.OpenRead(URLAddress);
StreamReader reader = new StreamReader(str);
byte[] mbyte = new byte[];
int allmybyte = (int)mbyte.Length;
int startmbyte = ; while (allmybyte > )
{ int m = str.Read(mbyte, startmbyte, allmybyte);
if (m == )
break; startmbyte += m;
allmybyte -= m;
} reader.Dispose();
str.Dispose(); string path = receivePath + System.IO.Path.GetFileName(URLAddress);
FileStream fstr = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
fstr.Write(mbyte, , startmbyte);
fstr.Flush();
fstr.Close();

原文链接

相关连接         C#实现文件下载的几种方式

最新文章

  1. Dapper学习笔记(2)-链接引用
  2. 除法取模练习(51nod 1119 & 1013 )
  3. JavaScript Patterns 5.6 Static Members
  4. C#程序
  5. 《C#编程》课件 - C#基础
  6. Image对象及其子类BufferedImage
  7. c语言操作符 “++”另类行为
  8. 折叠Collapse插件
  9. Linq无聊练习系列1--where练习
  10. R 包 安装 卸载 查看版本
  11. JavaScript(第十二天)【基本包装类型】
  12. of_alias_get_id 函数与设备树中aliases节点的关系【转】
  13. 【.net】未在本地计算机上注册“microsoft.ACE.oledb.12.0”提供程序解决办法
  14. htop使用详解
  15. css学习_写法规范、选择器
  16. python-----多线程、线程池、进程池
  17. logging 模块 五星知识
  18. KSOA单据保护表中Clientid解析为mac和ip
  19. JS的压缩、混淆、加密
  20. hadoop框架结构介绍

热门文章

  1. 3ds Max学习日记(三)
  2. 某一线互联网公司前端面试题js部分总结
  3. 【APS.NET Core】- Json配置文件的读取
  4. mysql指定编码格式创建数据库
  5. Android 布局方式学习
  6. 【bzoj2588】Spoj 10628. Count on a tree 离散化+主席树
  7. CentOS 用户管理useradd、usermod等
  8. CentOS 配置无线网络,开启wifi
  9. Android 数据库升级中数据保持和导入已有数据库
  10. BZOJ3172:[TJOI2013]单词——题解