[求助]如何判断远程返回的文件列表是文件夹还是文件???
请看代码,这是代码的一部分,所以大家不用管它能不能运行,只是请问大侠们,我返回的是一个string[]例表,这里面有文件夹与文件,然后用什么方法能判断出哪些是文件夹,哪些是文件呢??public string[] GetFileList()
{
FtpWebRequest reqFTP;
string[] downloadFiles;
StringBuilder result = new StringBuilder();
Reset();
try
{
if (_remotePath == "" || _remotePath == null)
{
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(_remoteHost + "/"));
}
else
{
reqFTP =(FtpWebRequest)FtpWebRequest.Create(new Uri(_remoteHost + "/"+_remotePath +"/"));
}
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential(_userName, _password);
reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
WebResponse response = reqFTP.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string line = reader.ReadLine();
while (line != null)
{
result.Append(line);
result.Append("\n");
line = reader.ReadLine();
}
result.Remove(result.ToString().LastIndexOf('\n'), 1);
reader.Close();
response.Close();
return result.ToString().Split('\n');
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
downloadFiles = null;
return downloadFiles;
}
}