Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: Delete directory recursive

$
0
0

Hi again, is there a method to recursively delete a directory or should i implement it ?

Edit:  no big deal this should work ok:

///<summary>/// Deletes the directory recursively.///</summary>///<param name="remoteDirectory">The remote directory.</param>protectedvoid DeleteDirectoryRecursive(string remoteDirectory)
        {
            if (!Client.Exists(remoteDirectory))
                return;

            foreach (var file in Client.ListDirectory(remoteDirectory))
            {
                if (file.Name.Equals(".") || file.Name.Equals(".."))
                    continue;

                if (file.IsDirectory)
                    DeleteDirectoryRecursive(file.FullName);
                else
                    Client.DeleteFile(file.FullName);
            }

            Client.DeleteDirectory(remoteDirectory);
        }

 

Thanks


Viewing all articles
Browse latest Browse all 1729

Trending Articles