I have some recursive code to operate FtpWebResponse objects, but it always return an error in the recursion.

Code
private void DownloadFolder(string _strFolderName)
{
string strFolderURL = this.strFTPURL + "/" + _strFolderName;
try
{
StringBuilder result = new StringBuilder();
StreamReader reader = null;
FtpWebRequest listRequest =
(FtpWebRequest)WebRequest.Create(strFolderURL);
listRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
FtpWebResponse listResponse =
(FtpWebResponse)listRequest.GetResponse();
reader = new StreamReader(listResponse.GetResponseStream());
//directories
if(IsDirectory)
{
this.DownloadFolder(_strFolderName + "/" + strInfo[strInfo.Length - 1]);
}
//files
else
{
this.DownloadFile(_strFolderName, strInfo[strInfo.Length - 1]);
}
}
reader.Close();
listResponse.Close();
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
Error: The operation has timed out.
Solution:
System.Net.ServicePointManager.DefaultConnectionLimit = 100; //any number you like
Causation:
While running into recursion, the FtpWebResponse object in parent function is still unclosed, the connection become more and more, but its default value is 2 only like below:

Code
//
// Summary:
// Gets or sets the maximum number of concurrent connections allowed by a System.Net.ServicePoint
// object.
//
// Returns:
// The maximum number of concurrent connections allowed by a System.Net.ServicePoint
// object. The default value is 2.
//
// Exceptions:
// System.ArgumentOutOfRangeException:
// System.Net.ServicePointManager.DefaultConnectionLimit is less than or equal
// to 0.
public static int DefaultConnectionLimit { get; set; }