Recursive calls not allowed - Deleting a directory

Advertisement

KLH
Guest

Recursive calls not allowed - Deleting a directory

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

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.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: Recursive calls not allowed - Deleting a directory

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.

Reply with quote

KLH
Guest

Sorry Martin.

The stuff above the seperator is from my ftpsSession class

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.

Reply with quote

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.

Reply with quote

Advertisement

You can post new topics in this forum