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. Linux驱动程序学习【转】

    本文转载自: 一直在学习驱动,对于下面这篇文章,本人觉得简洁明了,基本符合我们学习驱动的进度与过程,现转发到自己的博客,希望能与更多的朋友分享. 了解Linux驱动程序技巧学习的方法很重要,学习lin ...

  2. 马士兵Java视频教程 —— 学习顺序

    第一部分:J2se学习视频内容包括: 尚学堂科技_马士兵_JAVA视频教程_JDK5.0_下载-安装-配置 尚学堂科技_马士兵_JAVA视频教程_J2SE_5.0_第01章_JAVA简介_源代码_及重 ...

  3. MVC系列1-MVC基础 (ASP.NET)

    终于决定写一个系列的文章了,最开始其实是准备写一下WPF的,因为我这两年一直在做WPF,对WPF的喜爱自然是无以言表.但是由于我所在的地区对WPF的普及不是很广泛,所以,被迫又开始做起来web,但是我 ...

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

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

  5. java树形目录展示

    package test; import java.awt.Component;import java.awt.Container;import java.util.ArrayList;import ...

  6. ThreadLocal是什么?保证线程安全

    早在JDK 1.2的版本中就提供Java.lang.ThreadLocal,ThreadLocal为解决多线程程序的并发问题提供了一种新的思路.使用这个工具类可以很简洁地编写出优美的多线程程序. 当使 ...

  7. 20161014001 DataGridView 单元格内容 自动计算

    private void T_Form_CY_CBD_D_CellValueChanged(object sender, DataGridViewCellEventArgs e)        {   ...

  8. 关于小黄车(ofo共享单车)使用的问题

    小黄车即ofo共享单车,号称是全球创立最早.成长最快.规模最大的无桩共享单车创业公司,缔造了"共享单车"概念,致力于解决城市出行问题.它的出现给大家带来了方便,作为一个商业运行的公 ...

  9. H2数据库攻略

    H2是一个开源的嵌入式数据库引擎,采用java语言编写,不受平台的限制,同时H2提供了一个十分方便的web控制台用于操作和管理数据库内容.H2还提供兼容模式,可以兼容一些主流的数据库,因此采用H2作为 ...

  10. angular手势事件之on-Hold

    .controller( 'actionsheetCtl',['$scope',function($scope){ $scope.onHold=function(){ console.log(even ...