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. 修改tnsnames.ora文件中配置内容中的连接别名后,连接超时解决办法

    1.tnsnames.ora文件中配置内容中的连接别名:由upaydb修改为IP地址 2.连接超时 定位原因: PLSQL登录界面的数据库列表就是读的tnsname.ora中连接的别名,这个文件中连接 ...

  2. MVC,MVP 和 MVVM

    复杂的软件必须有清晰合理的架构,否则无法开发和维护.MVC(Model-View-Controller)是最常见的软件架构之一,业界有着广泛应用.它本身很容易理解,但是要讲清楚,它与衍生的 MVP 和 ...

  3. Linux下运行Jmeter测试所遇问题汇总

    一.安装及启动Jmeter  本文原创,专为光荣之路公众号所有,欢迎转发,但转发请务必写出处!  0.下载及安装 下载地址及Linux命令 wget http://mirrors.cnnic.cn/a ...

  4. A ship is always safe at the shore - but that is not what it is built for.

    A ship is always safe at the shore - but that is not what it is built for. 船靠岸边总是安全的,但那不是建造它的目的.

  5. JS子父窗口互相操作取值赋值的方法介绍

    $("#父窗口元素ID",window.parent.document); 对应javascript版本为window.parent.document.getElementById ...

  6. 判断浏览器是pc端还是手机端

    1. 判断浏览器是pc端还是手机端 <script type="text/javascript"> var browser = { versions: function ...

  7. c++源文件后缀名

    C中: 头文件后缀名: .h 源文件后缀名: .c C++中: 头文件后缀名: .h,   .hpp,   .hxx 源文件后缀名:.cpp,   .cc,   .cxx,   .C   .c++ 现 ...

  8. 【HDU2255】奔小康赚大钱-KM算法

    Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description ...

  9. dir、help查询

    #!/usr/bin/env python li = [] print(dir(li)) help(list)

  10. Navigator

      Navigator   这是一个简单的例子,用Navigator来跳转页面,页面之间传递参数 (代码是ES6语法写的): import React from 'react'; import { V ...