private bool DirectoryExists(String path) { foreach (FtpListener item in FtpListenerManager.GetFtpManager().Listeners) { foreach (String prefix in item.Prefixes) { if (prefix.Length >= path.Length && path.Equals(prefix.Substring(0, path.Length))) { return(true); } } } return(false); }
private static void WriteDirInfo(string path, FtpResponseStream stream) { ArrayList sent = new ArrayList(); foreach (FtpListener item in FtpListenerManager.GetFtpManager().Listeners) { foreach (String prefix in item.Prefixes) { if (prefix.Length >= path.Length && path.Equals(prefix.Substring(0, path.Length))) { //this is "our" directory String rest = prefix.Substring(path.Length); int idx = rest.IndexOf("/"); if (idx >= 0) { rest = rest.Substring(0, idx); } if (rest.Length < 1) { continue; } bool alreadySent = false; foreach (var itemSent in sent) { if (rest.Equals(itemSent)) { alreadySent = true; break; } } if (alreadySent) { continue; } sent.Add(rest); DirectoryInfo dir = new DirectoryInfo(rest); stream.Write(new DirectoryInfo(rest)); } } } }