Hey man did you ever figure out how to close the ftpwebrequest connection
What i am doing is take the root directory and having the FtpWebResponse send me the subdirectorys.... That works fine; UNTIL i try to get the subDirectoys of the subDirectorys and i keep getting this error telling me 505 file not found or file in use ( i know the files are their ) this has to do with a connection still open; and i can not force it closed...
Do you have any suggestions for me..
thanks alot
erik
public static List<FileDirInfo> GetFileAndDirNames(string remotePathUri)
{
if (remotePathUri.EndsWith("/"))
remotePathUri= remotePathUri.Remove(remotePathUri.Length - 1);
WebRequest ftp = BuildFtpWebRequest(new Uri(remotePathUri));
ftp.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
//
List<FileDirInfo> result = new List<FileDirInfo>();
//
try
{ //
using (WebResponse response = (WebResponse)ftp.GetResponse())
{ //
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{ //
string line = reader.ReadLine();
while (line != null)
{
//make the structure
result.Add(MakeReady(remotePathUri, line));
line = reader.ReadLine();
}
reader.Close();
} //
response.Close();
} //
}
catch (WebException e)
{
System.Windows.Forms. MessageBox.Show(((HttpWebResponse)e.Response).StatusCode.ToString());
}
catch (Exception e)
{
System.Windows.Forms. MessageBox.Show(e.Message);
}
finally { }
return result;
}
|