Esempio n. 1
0
        /// <summary>
        ///     Delete a remote folder and everything inside it
        /// </summary>
        /// <param name="path">Path to folder that will be deleted</param>
        /// <param name="skipIgnored">if true, files that are normally ignored will not be deleted</param>
        public void RemoveFolder(string path, bool skipIgnored = true)
        {
            if (!Exists(path))
            {
                return;
            }

            Log.Write(l.Client, "About to delete: {0}", path);
            // Empty the folder before deleting it
            // List is reversed to delete an files before their parent folders
            foreach (var i in ListRecursive(path, skipIgnored).Reverse())
            {
                Console.Write("\r Removing: {0,50}", i.FullPath);
                if (i.Type == ClientItemType.File)
                {
                    Remove(i.FullPath);
                }
                else
                {
                    lock (ftpcLock)
                    {
                        _sftpc.DeleteDirectory(i.FullPath);
                    }
                }
            }

            lock (ftpcLock)
            {
                _sftpc.DeleteDirectory(path);
            }

            Log.Write(l.Client, "Deleted: {0}", path);
        }