Topic "Recursive calls not allowed - Deleting a directory"

Author Message
KLH

Guest


I have established that directories exist. I go through the rfi.names list to removed them but always get the Recursive calls not allowed.

Code:

public RemovalOperationResult RemoveFiles(string path)
    {
        using (Session session = new Session())
        {
          session.Open(Config.FtpSessionOptions);
          return session.RemoveFiles(session.EscapeFileMask(path));
        }
    }
----------------------------------------------------
 RemoteDirectoryInfo rdi = ftpsSession.ListDirectory(ftpPath);
 foreach (RemoteFileInfo rfi in rdi.Files)
 {
    if (rfi.IsDirectory)
      {

         RemovalOperationResult ror;
         ror = ftpsSession.RemoveFiles(ftpPath + rfi.Name);
         if (ror.IsSuccess)
         {
         foreach (RemovalEventArgs removal in ror.Removals){
            log.Event("Removal of " + removal.FileName + " succeeded");
         }
     }
     else
     {
         log.Event("Removal failed.");
         return false;
     }


It doesn't seem to matter what the path is.
It does seem to be resolving to the right point. Everything else I am doing besides removal is working happily. I am very confused.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Your duplicate post on Stack Overflow:
<invalid hyperlink removed by admin>

While this post includes more code, it's not clear what is the ftpsSession and whether the ftpsSession.RemoveFiles is calling WinSCP Session.RemoveFiles or your RemoveFiles method.
KLH

Guest


Sorry Martin.

The stuff above the seperator is from my ftpsSession class

Code:
class FtpsSession
    {
public RemovalOperationResult RemoveFiles(string path)
    {
        using (WinSCP.Session session = new WinSCP.Session())
        {
          session.Open(Config.FtpSessionOptions);
          return session.RemoveFiles(session.EscapeFileMask(path));
        }
    }
}


I hope that makes it clearer.
Guest




With the problem being related to the WinSCP.Lock, I tried adding a Thread.Sleep(3000) to give it some time to clear itself out before attempting the removal. This might have solved the issue as it appears to be working, but it feels a bit clunky.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
No it does not make it any more clearer. The code your have posted just works. Please post Minimal, Complete, and Verifiable example
http://stackoverflow.com/help/mcve
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License