简体   繁体   中英

Downloading files from multiple directory in one FTP Connection with FTPWebRequest in .NET

Is it possible to change the Path of the FTP session once the Session is Open. The reason I want to do this is to avoid to open the multiple FTP connection. The whole purpose is to download the files located in the FTP site in a single FTP connection. For example, in single FTP connection, I want download the contens from all the directory located in the FTP site. Currently, I have project that is failing everyday because It makes multiple connections to the FTP site to download files from different directory . For example, making more than 80 connections in 1 minutes.

What are restrictions of the FTPWebRequest in .NET

As per the documentation for FtpWebRequest :

Multiple FtpWebRequests reuse existing connections, if possible.

Admittedly that does not really tell you much but if you look at the documentation for the ConnectionGroupName property, it tells you that you can specify the same ConnectionGroupName for multiple requests in order to reuse the connection.

Here is more information on managing connections in .NET.

Alternatively, you should be able to use the WebClient class to issue multiple related FTP requests and although I can't say for sure, I would imagine that it would reuse the connection. Unlike FtpWebRequest which can only be used once, WebClient can be used to make multiple requests.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM