They say that Dentist have a high rate of sucide; however, i think that developers could fall into that catagory also..
I am using the FtpWebRequest and FtpWebResponse to retrieve directory and file info from an ftp server... Everthing works fine for the first go to the server; however , on the second go i get an 505 not found or in use.. I know that the files are their becuae i am looking at them in IE. Not only that i can get the files that are not found in the first request by simple makeing them the first request..
Here is what i am doing..
Pass in root to get its subDirectorys
Then i would like to loop and get the subDirectorys ; subDirectorys
Can someone tell me where i am going wrong here?
Below is the only code that hits the network.. How can i force close, or what can i do to work around?
thanks
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;
}