我有这个代码的问题..代码给我这个文件名:
"."
"orders00001.xml"
".."
"orders00010.xml"
但文件夹中只有 order00001 和 order 00010.xml。请问您知道问题出在哪里吗?
private void getFileList()
{
List<string> files = new List<string>();
try
{
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(****);
request.Method = WebRequestMethods.Ftp.ListDirectory;
request.Credentials = new NetworkCredential(**, **);
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = false;
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
while (!reader.EndOfStream)
{
Application.DoEvents();
files.Add(reader.ReadLine());
}
reader.Close();
responseStream.Close(); //redundant
response.Close();
}
catch (Exception)
{
MessageBox.Show("error connecting");
}
if (files.Count != 0)
{
foreach (string file in files)
{
//My code on work with xml
}
else
{
getFileList();
}
}