Multi-thread download (FtpWebRequest)

Source: Internet
Author: User

I did not find any information for multi-threaded download of FtpWebRequest on the Internet. I wrote one myself. The test results are as follows:

// 1 thread downloads 133 M 18 seconds
// 5 threads download 133 M 40 seconds

// Download 133 MB for 12 seconds in a single thread

Hope you can give me some advice. The following is the complete code

First, namespace

Using System. Collections. Generic;
Using System. IO;
Using System. Threading;
Using System. Net;

Class subject:

Code Public class MultiFtpService
{
# Region variable

Private string _ Server; // Server address
Private string _ UserName; // User Name
Private string _ Password; // Password
Private int _ Port; // Port
Private long _ FileSize; // File Size
Private string _ FileUrl; // file address
Private string _ SavePath; // Save the path
Private string _ SaveFileName; // save the file name
Private string _ SaveExtName; // save the file extension
Private int _ ThreadNum; // Number of threads
Private short _ ThreadCompleteNum; // number of completed threads
Private bool _ IsComplete = false; // whether the process is complete
Private volatile int _ DownloadSize; // current download size
Private Thread [] _ Thread; // Thread Array
Private Li

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.