Exemple #1
0
        /// <summary>
        /// 获取当前目录下明细(包含文件和文件夹)
        /// </summary>
        /// <param name="remotePath">远程路径</param>
        /// <param name="type">查找文件的类别</param>
        /// <param name="mask">查找文件的正则</param>
        /// <returns></returns>
        public List <FtpFileInfo> GetFilesDetailList(string remotePath, FtpFileType type, Regex mask)
        {
            List <FtpFileInfo> result = new List <FtpFileInfo>();

            FtpWebRequest request = initRequest(remotePath, WebRequestMethods.Ftp.ListDirectoryDetails);

            using (WebResponse resp = request.GetResponse())
            {
                using (StreamReader reader = new StreamReader(resp.GetResponseStream()))
                {
                    while (!reader.EndOfStream)
                    {
                        string      line     = reader.ReadLine();
                        FtpFileInfo fileInfo = new FtpFileInfo(line);
                        if ((type == FtpFileType.ALL) || (type == FtpFileType.ONLY_FILE && !fileInfo.IsFolder) && (type == FtpFileType.ONLY_DIR && fileInfo.IsFolder))
                        {
                            if (mask == null || mask.Match(fileInfo.Name).Success)
                            {
                                result.Add(fileInfo);
                            }
                        }
                    }
                    ;
                };
            }
            return(result);
        }
Exemple #2
0
 public List <FtpFileInfo> GetFilesDetailList(string remotePath, FtpFileType type)
 {
     return(GetFilesDetailList(remotePath, type, null));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FtpTransferMode"/> class.
 /// </summary>
 /// <param name="fileType">The file data type of this transfer mode.</param>
 public FtpTransferMode(FtpFileType fileType)
 {
     FileType = fileType;
 }
 private FtpTransferMode(FtpFileType fileType, string interpretationMode)
     : this(fileType)
 {
     ParseInterpretationMode(interpretationMode);
 }
 public FtpFileProperties(string name, FtpFileType type)
 {
     Name = name;
     Type = type;
 }
Exemple #6
0
 public List<FtpFileInfo> GetFilesDetailList(string remotePath, FtpFileType type)
 {
     return GetFilesDetailList(remotePath, type, null);
 }
Exemple #7
0
        /// <summary>
        /// 获取当前目录下明细(包含文件和文件夹)
        /// </summary>
        /// <param name="remotePath">远程路径</param>
        /// <param name="type">查找文件的类别</param>
        /// <param name="mask">查找文件的正则</param>
        /// <returns></returns>
        public List<FtpFileInfo> GetFilesDetailList(string remotePath, FtpFileType type, Regex mask)
        {
            List<FtpFileInfo> result = new List<FtpFileInfo>();

            FtpWebRequest request = initRequest(remotePath, WebRequestMethods.Ftp.ListDirectoryDetails);
            using (WebResponse resp = request.GetResponse())
            {
                using (StreamReader reader = new StreamReader(resp.GetResponseStream()))
                {
                    while (!reader.EndOfStream)
                    {
                        string line = reader.ReadLine();
                        FtpFileInfo fileInfo = new FtpFileInfo(line);
                        if ((type == FtpFileType.ALL) || (type == FtpFileType.ONLY_FILE && !fileInfo.IsFolder) && (type == FtpFileType.ONLY_DIR && fileInfo.IsFolder))
                        {
                            if (mask == null || mask.Match(fileInfo.Name).Success)
                            {
                                result.Add(fileInfo);
                            }
                        }
                    };
                };
            }
            return result;
        }
Exemple #8
0
 private FtpTransferMode(FtpFileType fileType, string interpretationMode)
     : this(fileType)
 {
     ParseInterpretationMode(interpretationMode);
 }
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FtpTransferMode"/> class.
 /// </summary>
 /// <param name="fileType">The file data type of this transfer mode</param>
 public FtpTransferMode(FtpFileType fileType)
 {
     FileType = fileType;
 }