Esempio n. 1
0
        /// <summary>
        /// Return a detailed directory listing, and also download datetime stamps if specified
        /// </summary>
        /// <param name="directory">Directory to list, e.g. /pub/etc</param>
        /// <param name="doDateTimeStamp">Boolean: set to True to download the datetime stamp for files</param>
        /// <returns>An FTPDirectory object</returns>
        public FTPdirectory ListDirectoryDetail(string directory, bool doDateTimeStamp)
        {
            String URI = GetDirectory(directory);

            System.Net.FtpWebRequest ftp = GetRequest(URI);
            // Set request to do simple list
            ftp.Method = System.Net.WebRequestMethods.Ftp.ListDirectoryDetails;

            string str = GetStringResponse(ftp);

            // replace CRLF to CR, remove last instance
            str = str.Replace("\r\n", "\r").TrimEnd('\r');
            // split the string into a list
            FTPdirectory dir = new FTPdirectory(str, _lastDirectory);

            // download timestamps if requested
            if (doDateTimeStamp)
            {
                foreach (FTPfileInfo fi in dir)
                {
                    fi.FileDateTime = this.GetDateTimestamp(fi);
                }
            }

            return(dir);
        }
Esempio n. 2
0
        //internal: share use function for GetDirectories/Files
        private FTPdirectory GetFileOrDir(FTPfileInfo.DirectoryEntryTypes type, string ext)
        {
            FTPdirectory result = new FTPdirectory();

            foreach (FTPfileInfo fi in this)
            {
                if (fi.FileType == type)
                {
                    if (ext == "")
                    {
                        result.Add(fi);
                    }
                    else if (ext == fi.Extension)
                    {
                        result.Add(fi);
                    }
                }
            }
            return(result);
        }