资源简介
利用c# 简单实现基于http的文件下载,带进度条。暂不支持断点续传。

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Threading;
namespace DownLoadHttp
{
public partial class Form1 : Form
{
public Form1()
{
//防止线程间操作无效
//如果不写,会产生:
//线程间操作无效: 从不是创建控件“btnDown”的线程访问它。
//因为控件的创建在另外一个线程。
Control.CheckForIllegalCrossThreadCalls = false;
InitializeComponent();
this.txtSrcAddress.Text = @“http://www.100-try.com/soft/Viewdll.rar“;
this.txtTarAddress.Text = @“D:“;
}
private void btnDown_Click(object sender EventArgs e)
{
Thread th = new Thread(new ThreadStart(this.StartDownLoad));
th.Start();
}
private void StartDownLoad()
{
this.btnDown.Enabled = false;
this.statusBar.Text = “正在下载...“;
//要下载的文件http地址
//例如:(http://www.YourSiteAddress.com/SoftWare/Soft1.rar)
string url = this.txtSrcAddress.Text;
//截取文件名称
int n = url.LastIndexOf(‘/‘);
string fileName = url.Substring(n + 1 url.Length - n - 1);
//保存的路径+\文件名
string dir = this.txtTarAddress.Text;
string filepath = dir+“\\“+fileName;
HttpDownLoad httpDownLoad = new HttpDownLoad();
httpDownLoad.httpDownFile(urlfilepath this.toolStripProgressBar this.toolStripStatusLabel);
this.btnDown.Enabled = true;
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 12288 2009-10-09 16:09 DownLoadHttp\bin\Debug\DownLoadHttp.exe
文件 30208 2009-10-09 16:09 DownLoadHttp\bin\Debug\DownLoadHttp.pdb
文件 14328 2009-10-09 16:13 DownLoadHttp\bin\Debug\DownLoadHttp.vshost.exe
文件 490 2007-07-21 01:33 DownLoadHttp\bin\Debug\DownLoadHttp.vshost.exe.manifest
文件 828 2009-10-09 11:19 DownLoadHttp\bin\Debug\test.txt
文件 493568 2009-10-09 14:28 DownLoadHttp\bin\Debug\Viewdll.exe
文件 202351 2009-10-09 15:04 DownLoadHttp\bin\Debug\viewdll.rar
文件 29696 2009-10-09 14:31 DownLoadHttp\bin\Debug\单项制作规范.doc
文件 3399 2009-10-09 16:13 DownLoadHttp\DownLoadHttp.csproj
文件 913 2009-10-09 16:13 DownLoadHttp\DownLoadHttp.sln
..A..H. 10240 2009-10-09 16:13 DownLoadHttp\DownLoadHttp.suo
文件 1894 2009-10-09 16:09 DownLoadHttp\Form1.cs
文件 6065 2009-10-09 16:09 DownLoadHttp\Form1.Designer.cs
文件 6011 2009-10-09 16:09 DownLoadHttp\Form1.resx
文件 5604 2009-10-09 16:08 DownLoadHttp\HttpDownLoad.cs
文件 647 2009-10-09 16:13 DownLoadHttp\obj\Debug\DownLoadHttp.csproj.FileListAbsolute.txt
文件 847 2009-10-09 16:09 DownLoadHttp\obj\Debug\DownLoadHttp.csproj.GenerateResource.Cache
文件 12288 2009-10-09 16:09 DownLoadHttp\obj\Debug\DownLoadHttp.exe
文件 180 2009-10-09 16:09 DownLoadHttp\obj\Debug\DownLoadHttp.Form1.resources
文件 30208 2009-10-09 16:09 DownLoadHttp\obj\Debug\DownLoadHttp.pdb
文件 180 2009-10-09 15:41 DownLoadHttp\obj\Debug\DownLoadHttp.Properties.Resources.resources
文件 473 2009-10-09 09:45 DownLoadHttp\Program.cs
文件 1368 2009-10-09 09:45 DownLoadHttp\Properties\AssemblyInfo.cs
文件 2874 2009-10-09 09:45 DownLoadHttp\Properties\Resources.Designer.cs
文件 5612 2009-10-09 09:45 DownLoadHttp\Properties\Resources.resx
文件 1097 2009-10-09 09:45 DownLoadHttp\Properties\Settings.Designer.cs
文件 249 2009-10-09 09:45 DownLoadHttp\Properties\Settings.settings
目录 0 2009-10-09 16:12 DownLoadHttp\obj\Debug\Refactor
目录 0 2009-10-09 16:12 DownLoadHttp\obj\Debug\TempPE
目录 0 2009-10-09 16:12 DownLoadHttp\bin\Debug
............此处省略8个文件信息
相关资源
- C# TIP文件生成和拆解
- C#解析HL7消息的库135797
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- Winform可视化打印模板设计工具含源码
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
评论
共有 条评论