Beispiel #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 FtpDirectoryInfo ListDirectoryDetail(string directory, bool doDateTimeStamp)
        {
            FtpWebRequest ftp = GetRequest(GetDirectory(directory));

            // Set request to do simple list
            ftp.Method = 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
            FtpDirectoryInfo dir = new FtpDirectoryInfo(str, _lastDirectory);

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

            return(dir);
        }
Beispiel #2
0
        //internal: share use function for GetDirectories/Files
        private FtpDirectoryInfo GetFileOrDir(FtpFileInfo.DirectoryEntryTypes type, string ext)
        {
            FtpDirectoryInfo result = new FtpDirectoryInfo();

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