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多任务下载实现类的更多相关文章

  1. ftp上传下载工具类

    package com.taotao.utils; import java.io.File; import java.io.FileInputStream; import java.io.FileNo ...

  2. 使用递归方法实现,向FTP服务器上传整个目录结构、从FTP服务器下载整个目录到本地的功能

    我最近由于在做一个关于FTP文件上传和下载的功能时候,发现Apache FTP jar包没有提供对整个目录结构的上传和下载功能,只能非目录类型的文件进行上传和下载操作,后来我查阅很多网上的实现方法,再 ...

  3. (4)FTP服务器下载文件

    上一篇中,我们提到了怎么从FTP服务器下载文件.现在来具体讲述一下. 首先是路径配置.. 所以此处我们需要一个app.config来设置路径. <?xml version="1.0&q ...

  4. C#- FTP递归下载文件

    c# ftp递归下载文件,找来找去这个最好.(打断点,一小处foreach要改成for) /// <summary> /// ftp文件上传.下载操作类 /// </summary& ...

  5. DownloadManager 下载管理类

    演示 简介 从Android 2.3开始新增了一个下载管理类,在SDK的文档中我们查找android.app.DownloadManager可以看到.下载管理类可以长期处理多个HTTP下载任务,客户端 ...

  6. Python之FTP多线程下载文件之分块多线程文件合并

    Python之FTP多线程下载文件之分块多线程文件合并 欢迎大家阅读Python之FTP多线程下载系列之二:Python之FTP多线程下载文件之分块多线程文件合并,本系列的第一篇:Python之FTP ...

  7. 【FTP】C# System.Net.FtpClient库连接ftp服务器(下载文件)

    如果自己单枪匹马写一个连接ftp服务器代码那是相当恐怖的(socket通信),有一个评价较高的dll库可以供我们使用. 那就是System.Net.FtpClient,链接地址:https://net ...

  8. android 关于多任务下载问题

    关于多任务下载问题    近期项目中,遇到一个问题,列表数据中的图片地址是一个需要下载JS再解析的字段,之前的图片下载是一个异步的过程,由一个队列处理. Android系统以不同寻常的方式处理多个应用 ...

  9. 通过cmd命令到ftp上下载文件

    通过cmd命令到ftp上下载文件 点击"开始"菜单.然后输入"cmd"点"enter"键,出现cmd命令执行框 2 输入"ftp& ...

随机推荐

  1. U-Boot移植

    基于天翔的老师的课程, 他的博客在这儿: http://blog.csdn.net/johnmcu/article/details/6561311 注明不能转载, 就重新写一下吧: 1. 安装韦东山的 ...

  2. Linux下PHP+MYSQL+APACHE配置方法

    apache: http://www.apache.org  mysql: http://www.mysql.com  php: http://www.php.net/downloads.php  g ...

  3. Python—RabbitMQ

    RabbitMQ RabbitMQ是一个在AMQP基础上完整的,可复用的企业消息系统 安装 因为RabbitMQ由erlang实现,先安装erlang #安装配置epel源 rpm -ivh http ...

  4. wps使用技巧

    1.和word一样的文档结构图: 视图->文档结构图 (不是导航窗格) 2.粘贴时,出现乱码: WPS->选项->默认粘贴方式:无格式文本. 3.浏览当前文档所在目录: 在WPS的标 ...

  5. bzoj1007[HNOI2008]水平可见直线

    cycleke神说要用半平面交(其实他也用的凸包),把我吓了一跳,后来发现(看题解)其实可以先按斜率排序,再将最小的两条线入栈,如果其与栈顶元素的交点在上一个点的左边,则将栈顶元素出栈.这是一个开口向 ...

  6. Big String-POJ2887块状数组

    Time Limit: 1000MS Memory Limit: 131072K Description You are given a string and supposed to do some ...

  7. 【ASM C/C++】 Makefile 规则说明

    make 命令会自动读取当前目录下的 Makefile 文件[31],完成相应的编译步骤.Makefile 由一组规则(Rule)组成,每条规则的格式是:target ... : prerequisi ...

  8. DDS转换工具

    本工具用于将(长宽均为 2 的指数次幂的)图像文件如 PNG.TGA.BMP.JPG 等转换为 DDS 图像(DXT 压缩类型可选,DXT1~DXT5),也可将 DDS 图像转换回此几种格式图片. 截 ...

  9. 【Spring】简单的Spring AOP注解示例

    引入相关包: <properties> <spring.version>3.0.5.RELEASE</spring.version> <aspectj.ver ...

  10. JS作用域及call

    <script type="text/javascript"> function log(val){ console.log(val); } function base ...