예제 #1
0
        private List <string> Search(string baseAddr, string query, List <DirectoryItem> directories)
        {
            List <string> matches = new List <string>();

            foreach (DirectoryItem item in directories)
            {
                if (item.IsDirectory)
                {
                    string cd = FtpUtils.UriBuilder(baseAddr, item.Filename);
                    AddLine("Searching: " + cd);
                    try
                    {
                        List <DirectoryItem> newDir = FtpUtils.DirectoryListingParser(GetDirectoryListing(new RequestInfo()
                        {
                            Host = cd
                        }), baseAddr);
                        matches.AddRange(Search(cd, query, newDir));
                    }
                    catch (Exception)
                    {
                        AddLine("Searching folder " + cd);
                    }
                }
                if (FtpUtils.Match(query, item.Filename))
                {
                    matches.Add(FtpUtils.UriBuilder(baseAddr, item.Filename));
                }
            }
            return(matches);
        }
예제 #2
0
 public DirectoryItem(string basePath, string permissions, string inodes, string owner, string group, string size, string month, string day, string year, string filename, bool isDirectory)
 {
     this.BasePath    = basePath;
     this.Permissions = permissions;
     this.Inodes      = inodes;
     this.Owner       = owner;
     this.Group       = group;
     this.Size        = size;
     this.Month       = month;
     this.Day         = day;
     this.Year        = year;
     this.Filename    = filename;
     this.IsDirectory = isDirectory;
     FullPath         = FtpUtils.UriBuilder(BasePath, Filename);
 }
예제 #3
0
        public void Connect(string[] addresses, string searchQuery)
        {
            List <RequestInfo> allRequestInfo = FtpUtils.RequestInfoList(addresses);

            AddLine("Beginning conections...");
            foreach (RequestInfo info in allRequestInfo)
            {
                AddLine("Connecting to " + info.Host);
                try
                {
                    List <string> resultList = Search(info.Host, searchQuery, FtpUtils.DirectoryListingParser(GetDirectoryListing(info), info.Host));
                    AddLine("FOUND RESULTS:");
                    AddLines(resultList.ToArray());
                }
                catch (WebException)
                {
                    AddLine("WebException, Something failed.");
                }
            }
        }