Ejemplo n.º 1
0
		/// <summary>
		/// Initialize a new object representing a directory on the FTP server
		/// </summary>
		/// <param name="cl">The client this object is associated with</param>
		/// <param name="parent">The parent directory (if any)</param>
		/// <param name="listing">The file listing object that was parsed to get this object's data</param>
		public FtpDirectory(ThinkAway.Net.FTP.FtpClient cl, FtpDirectory parent, FtpListItem listing)
			: base(cl, string.Format("{0}/{1}", parent.FullName, listing.Name)) {
			this.LastWriteTime = listing.Modify;
			this.Parent = parent;
		}
		/// <summary>
		/// Tries to load the object information
		/// </summary>
		protected void GetInfo() {
			if(this.Client.HasCapability(FtpCapability.MLST)) {
				if(this.Client.Execute("MLST {0}", this.FullName)) {
					foreach(string s in this.Client.Messages) {
						if(s.StartsWith(" ")) { // MLST response begins with space according to internet draft
							FtpListItem i = new FtpListItem(s, FtpListType.MLST);

							if(i.Type == FtpObjectType.Directory) {
								this.LastWriteTime = i.Modify;
								return;
							}
							else if(i.Type == FtpObjectType.File) {
								this.LastWriteTime = i.Modify;
								this.Length = i.Size;
								return;
							}
						}
					}
				}
			}
			else {
				this.LastWriteTime = this.Client.GetLastWriteTime(this.FullName);
			}
		}
Ejemplo n.º 3
0
        /// <summary>
        /// Parses an array of list results
        /// </summary>
        /// <param name="items">Array of list results</param>
        /// <param name="type">The command that generated the list being parsed</param>
        /// <returns></returns>
        public static FtpListItem[] ParseList(string[] items, FtpListType type) {
            List<FtpListItem> lst = new List<FtpListItem>();

            foreach (string s in items) {
                FtpListItem i = new FtpListItem(s, type);

                if (i.Type != FtpObjectType.Unknown) {
                    lst.Add(i);
                }
            }

            return lst.ToArray();
        }