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. webService-cxf

    官网必备包,自己研究api:http://cxf.apache.org/download.html 然后就是一个简单的例子了: 先服务端: package com.cxf; import javax. ...

  2. [已解决] protobuf Missing input file

    如果proto描述文件在当前目录,要以"./"开始 如: protoc ./test.proto --java_out=./ 文章来源:http://www.cnblogs.com ...

  3. jqGrid subGrid配置 如何首次加载动态展开所有的子表格

    有时候需求需要默认加载表格的时候把子表格的数据也显示出来,经过研究相关SubGrids API配置如下: 属性 类型 描述 默认值 subGrid boolean 设置为true启用子表格.如果启用子 ...

  4. Oracle数据库的表结构 简单表的建立

  5. ADB server didn't ACK * failed to start daemon *

    问题描述:在eclipse的Logcat出现错误 [2014-01-08 14:00:07 - adb] ADB server didn't ACK [2014-01-08 14:00:07 - ad ...

  6. html热力图的操作(点击图片的不同位置操作不同的事件)适合说明文档

    页面核心代码 <div class="first_top"> <div class="back"> <img src=" ...

  7. boost学习笔记(七)---date_time库

    date_time库的日期基于格里高利历,支持从1400-01-01到9999-12-31之间的日期计算 #define BOOST_DATE_TIME_SOURCE #include <boo ...

  8. js 为字符串添加样式

    <html><body> <script type="text/javascript"> var txt="Hello World!& ...

  9. 6.Swift协议|扩展|访问权限|异常调试|类型转换|运算函数|ARC|类类型初试化器|值类型初始化器

    1. 协议(Protocol):与OC之间唯一不同的是Swift中的协议不管是属性还时方法全部是必须实现的 /** protocol*/ protocol FullNamed { /** 计算属性申明 ...

  10. JAVA 冒泡算法

    每种语言都有冒泡JAVA实现如下: public static void main(String args[]){ System.out.println("Start"); int ...