Beispiel #1
0
 /// <summary>
 /// Clean up this object and release all of it's resources.
 /// </summary>
 public override void Dispose()
 {
     base.Dispose();
     this._parent = null;
     this._files  = null;
     this._dirs   = null;
 }
Beispiel #2
0
 /// <summary>
 /// Delete this file
 /// </summary>
 public void Delete()
 {
     this.Parent.Delete(this);
     this.Length        = 0;
     this.LastWriteTime = DateTime.MinValue;
     this.Parent        = null;
 }
Beispiel #3
0
        /// <summary>
        /// Deletes the specified directory and removes it from the list of directories
        /// in this directory if it's there
        /// </summary>
        /// <param name="dir"></param>
        /// <param name="recursive"></param>
        public void Delete(FtpDirectory dir, bool recursive)
        {
            if (recursive)
            {
                if (dir.Files.Count > 0)
                {
                    foreach (FtpFile f in dir.Files.ToArray())
                    {
                        f.Delete();
                    }
                }

                if (dir.Directories.Count > 0)
                {
                    foreach (FtpDirectory d in dir.Directories.ToArray())
                    {
                        d.Delete(recursive);
                    }
                }
            }

            this.Client.RemoveDirectory(dir.FullName);

            if (this.Directories.Contains(dir))
            {
                this.Directories.Remove(dir);

#if DEBUG
                System.Diagnostics.Debug.WriteLine(string.Format("Removed {0} from my directory list!", dir.FullName));
#endif
            }
        }
Beispiel #4
0
 /// <summary>
 /// Constructs a new FtpFile object
 /// </summary>
 /// <param name="cl">The FtpClient to associate this FtpFile with</param>
 /// <param name="parent">The parent FtpDirectory if any</param>
 /// <param name="listing">The FtpListItem object that was acquired from parsing flie list from the server.</param>
 public FtpFile(ThinkAway.Net.FTP.FtpClient cl, FtpDirectory parent, FtpListItem listing)
     : base(cl, string.Format("{0}/{1}", parent.FullName, listing.Name))
 {
     this.Length        = listing.Size;
     this.LastWriteTime = listing.Modify;
     this.Parent        = parent;
 }
Beispiel #5
0
        /// <summary>
        /// Creates the specified sub directory
        /// </summary>
        /// <param name="name"></param>
        public FtpDirectory CreateDirectory(string name)
        {
            FtpDirectory fd = new FtpDirectory(this.Client, string.Format("{0}/{1}", this.FullName, name));

            fd.Parent = this;
            this.Client.CreateDirectory(string.Format("{0}/{1}", this.FullName, name));
            if (_dirs.Count > 0)
            {
                _dirs.Add(fd);
            }

            return(fd);
        }
Beispiel #6
0
        /// <summary>
        /// Delete this directory and all files and directories beneath it
        /// </summary>
        /// <param name="recursive"></param>
        public void Delete(bool recursive)
        {
            if (this.Parent != null)
            {
                this.Parent.Delete(this, recursive);
            }
            else
            {
                throw new FtpException("You can't remove the top level directory!");
            }

            this._files.Clear();
            this._dirs.Clear();
            this.Parent        = null;
            this.LastWriteTime = DateTime.MinValue;
        }
Beispiel #7
0
 /// <summary>
 /// Deletes the specified directory and removes it from the list of directories
 /// in this directory if it's there
 /// </summary>
 /// <param name="dir"></param>
 public void Delete(FtpDirectory dir)
 {
     this.Delete(dir, false);
 }
		/// <summary>
		/// Clean up this object and release all of it's resources.
		/// </summary>
		public override void Dispose() {
			base.Dispose();
			this._parent = null;
			this._files = null;
			this._dirs = null;
		}
		/// <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>
		/// Creates the specified sub directory
		/// </summary>
		/// <param name="name"></param>
		public FtpDirectory CreateDirectory(string name) {
			FtpDirectory fd = new FtpDirectory(this.Client, string.Format("{0}/{1}", this.FullName, name));

			fd.Parent = this;
			this.Client.CreateDirectory(string.Format("{0}/{1}", this.FullName, name));
			if(_dirs.Count > 0) {
				_dirs.Add(fd);
			}

			return fd;
		}
		/// <summary>
		/// Delete this directory and all files and directories beneath it
		/// </summary>
		/// <param name="recursive"></param>
		public void Delete(bool recursive) {
			if(this.Parent != null) {
				this.Parent.Delete(this, recursive);
			}
			else {
				throw new FtpException("You can't remove the top level directory!");
			}

			this._files.Clear();
			this._dirs.Clear();
			this.Parent = null;
			this.LastWriteTime = DateTime.MinValue;
		}
		/// <summary>
		/// Deletes the specified directory and removes it from the list of directories
		/// in this directory if it's there
		/// </summary>
		/// <param name="dir"></param>
		/// <param name="recursive"></param>
		public void Delete(FtpDirectory dir, bool recursive) {
			if(recursive) {
				if(dir.Files.Count > 0) {
					foreach(FtpFile f in dir.Files.ToArray()) {
						f.Delete();
					}
				}

				if(dir.Directories.Count > 0) {
					foreach(FtpDirectory d in dir.Directories.ToArray()) {
						d.Delete(recursive);
					}
				}
			}

			this.Client.RemoveDirectory(dir.FullName);

			if(this.Directories.Contains(dir)) {
				this.Directories.Remove(dir);

#if DEBUG
				System.Diagnostics.Debug.WriteLine(string.Format("Removed {0} from my directory list!", dir.FullName));
#endif
			}
		}
		/// <summary>
		/// Deletes the specified directory and removes it from the list of directories
		/// in this directory if it's there
		/// </summary>
		/// <param name="dir"></param>
		public void Delete(FtpDirectory dir) {
			this.Delete(dir, false);
		}
Beispiel #14
0
		/// <summary>
		/// Delete this file
		/// </summary>
		public void Delete() {
			this.Parent.Delete(this);
			this.Length = 0;
			this.LastWriteTime = DateTime.MinValue;
			this.Parent = null;
		}