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.
精彩评论