FTP多任务下载实现类
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Net;
using System.IO; namespace RSGIS.FTPClient
{
public partial class FormLoad : DevExpress.XtraEditors.XtraForm
{
private string host = "ftp://...:21";
private string user = "anonymous";
private string pass = "..."; private string strLocalFilePath = @"D:";
private string[] strLists;
private List<MultiFtpService> MultiThread = new List<MultiFtpService>();
public FormLoad(string[] strList)
{
InitializeComponent();
strLists = strList;
} public FormLoad()
{
InitializeComponent();
strLists = new string[3];
strLists[0] = “”
strLists[1] = “”
strLists[2] = “” private void buttonStart_Click(object sender, EventArgs e)
{
taskDo();
} private void buttonStop_Click(object sender, EventArgs e)
{
stop();
} private void buttonContinues_Click(object sender, EventArgs e)
{
continues();
}
//停止
private void stop()
{
for (int i = 0; i < MultiThread.Count; i++)
{
MultiThread[i].Stop();
}
}
//继续
private void continues()
{
for (int i = 0; i < MultiThread.Count; i++)
{
MultiThread[i].continues();
}
}
//下载
private void taskDo()
{
for (int i = 0; i < strLists.Length; i++)
{
string[] files = fileName(strLists[i], strLists[i].Substring(strLists[i].LastIndexOf("/") + 1));
MultiFtpService threads = new MultiFtpService(host, user, pass, i, i, files[0], files[1]);
MultiThread.Add(threads);
threads.WorkMethod += DisplayProgress;
threads.FileSpeedMethod += DisplaySpeed;
threads.Start();
}
}
//路径操作
private string[] fileName(string strRemoteFilePath, string strLocalFileName)
{
string strLocalFilePaths = strLocalFilePath + @"\" + strLocalFileName;
strLocalFilePaths.Replace("\\\\", "\\");
strRemoteFilePath.Replace("/", "\\");
string[] files = { strRemoteFilePath, strLocalFilePaths };
return files;
}
/// <summary>
/// 进度显示
/// </summary>
/// <param name="threadindex"></param>
/// <param name="taskindex"></param>
/// <param name="progress"></param>
private void DisplayProgress(int taskindex, int progress)
{
this.BeginInvoke(new MethodInvoker(delegate()
{
label1.Text = taskindex.ToString();
this.progressBar2.Value = progress;
if(progress == 100)
this.progressBar2.Value = progressBar2.Maximum;
}));
}
//下载速度显示
private void DisplaySpeed(int taskindex, string speed)
{
this.BeginInvoke(new MethodInvoker(delegate()
{
this.labelSpeed.Text = speed + "/s";
})); } }
}
FTP多任务下载实现类的更多相关文章
- ftp上传下载工具类
package com.taotao.utils; import java.io.File; import java.io.FileInputStream; import java.io.FileNo ...
- 使用递归方法实现,向FTP服务器上传整个目录结构、从FTP服务器下载整个目录到本地的功能
我最近由于在做一个关于FTP文件上传和下载的功能时候,发现Apache FTP jar包没有提供对整个目录结构的上传和下载功能,只能非目录类型的文件进行上传和下载操作,后来我查阅很多网上的实现方法,再 ...
- (4)FTP服务器下载文件
上一篇中,我们提到了怎么从FTP服务器下载文件.现在来具体讲述一下. 首先是路径配置.. 所以此处我们需要一个app.config来设置路径. <?xml version="1.0&q ...
- C#- FTP递归下载文件
c# ftp递归下载文件,找来找去这个最好.(打断点,一小处foreach要改成for) /// <summary> /// ftp文件上传.下载操作类 /// </summary& ...
- DownloadManager 下载管理类
演示 简介 从Android 2.3开始新增了一个下载管理类,在SDK的文档中我们查找android.app.DownloadManager可以看到.下载管理类可以长期处理多个HTTP下载任务,客户端 ...
- Python之FTP多线程下载文件之分块多线程文件合并
Python之FTP多线程下载文件之分块多线程文件合并 欢迎大家阅读Python之FTP多线程下载系列之二:Python之FTP多线程下载文件之分块多线程文件合并,本系列的第一篇:Python之FTP ...
- 【FTP】C# System.Net.FtpClient库连接ftp服务器(下载文件)
如果自己单枪匹马写一个连接ftp服务器代码那是相当恐怖的(socket通信),有一个评价较高的dll库可以供我们使用. 那就是System.Net.FtpClient,链接地址:https://net ...
- android 关于多任务下载问题
关于多任务下载问题 近期项目中,遇到一个问题,列表数据中的图片地址是一个需要下载JS再解析的字段,之前的图片下载是一个异步的过程,由一个队列处理. Android系统以不同寻常的方式处理多个应用 ...
- 通过cmd命令到ftp上下载文件
通过cmd命令到ftp上下载文件 点击"开始"菜单.然后输入"cmd"点"enter"键,出现cmd命令执行框 2 输入"ftp& ...
随机推荐
- 阿里yum源
转:http://mirrors.aliyun.com/help/centos?spm=5176.bbsr150321.0.0.d6ykiD 1.备份 mv /etc/yum.repos.d/Cent ...
- 压力测试工具JMeter入门教程
1.Jmeter 概要描叙 jmeter 是一款专门用于功能测试和压力测试的轻量级测试开发平台.多数情况下是用作压力测试,该测试工具在阿里巴巴有着广泛的使用,估计是不要钱吧,哈哈,功能上来说,整个平台 ...
- webstorm--破解
2016.2.2 版本的破解方式: 安装以后,打开软件会弹出一个对话框:选择"license server" 输入:http://114.215.133.70:41017 2016 ...
- XPlane android 2D手游开发实战
android 飞行射击游戏类 采用 xamarin 跨平台开发技术 纯C#语言编写 操作简单 1.手指拖动飞机 躲避敌机 2.通过吃敌机爆炸后遗落的物品增加各种属性 3.双击战机放大技能 4.目前 ...
- Navicat for MySQL安装之后不知道登录密码
1,关闭你现在正在运行的mysql数据库,关闭mysql服务器. 2,关闭数据库后,运行点击开始运行,输入cmd进入命令行窗口,在这个命令行中操作进入到你数据库所在的安装路径,一般默认安装的话都会在e ...
- thinkphp 查询当天 ,本周,本月,本季度,本年度,全部, 数据方法
数据库字段是createtime 里面保存的是时间戳 <?php /* *按今天,本周,本月,本季度,本年,全部查询预约单数据 * $day 代表查询条件 $cid 代表 公司id *返回arr ...
- oracle游标透彻详解分析
主:本文来自:http://www.cnblogs.com/huyong/archive/2011/05/04/2036377.html 4.1 游标概念 4.1.1 处理显式游标 4.1.2 处理隐 ...
- Android first--SharedPreferences
public class MainActivity extends Activity { private EditText et_name; private EditText et_pass; ...
- Xcode 8
(一)Xcode8去掉多余LOG 1.打开我们的项目,进入EditScheme 2.我们在Environment Variables中添加OS_ACTIVITY_MODE=disable
- Ubuntu-server14.04搭建LAMP环境
转自:http://www.cnblogs.com/myzhibie/p/4330327.html 对于很多PHP初学开发者来讲,搭建一个可用于生产的LAMP环境是一件费时费力的事情,本文以 ubun ...