Link to home
Start Free TrialLog in
Avatar of adlabac
adlabacFlag for Montenegro

asked on

FTP problem

I am trying to delete folder on FTP server with two files inside. The procedure is the following:

  1. Enter the folder;
  2. Delete the frist file (big one);
  3. Delete the second file (small one)
  4. Leave the folder
  5. Delete the folder

I always receive the message that folder is not empty (the big file is still there)! I am using Indy TIdFTP component from Delphi/C++ Builder:

  ChangeDir (FolderName);
  Delete (FileName1);
  Delete (FileName2);
  ChangeDirUp;
  RemoveDir (FolderName);

If I make a longer pause before RemoveDir method everything is OK! I tried to insert a loop before ChangeFolderUp method which checked if folder is empty once a second. After about 25 seconds the file was finaly deleted and everything finished OK!?!

TotalCommander finishes job fast, an there is nothing inside its log different from this I already did (except TC first tried to delete non-empty folder (RMD) and to delete it like it was file (DELE) prior to entering the folder and deleting its files.

Any idea what should I do to make it work fast?
Avatar of thundt2
thundt2

I'd try not ChangeDiring into that folder, and instead deleting foldername + filename.  In other words, eliminate steps 1 and 4 from your list.  (Perhaps the ftp server is slow to realize you aren't still visiting the folder.)
Avatar of adlabac

ASKER

Thank you for the answer!

Actually, I did it like you said the first time. Since it did not work, I tried to enter/leave folder just to be sure that I am not inside. Total comander does it the same way - enters, gets list of files, deletes every file, leaves and, finally, it deletes the folder.
The next thing I would try is look for a log from the ftp daemon -- see if it has more details on what you are doing vs what Commander is doing.
Avatar of adlabac

ASKER

Yes, I thought of that. The problem is that it is some non-standard FTP server in modified Windows version (by Ericsson), and I cannot find any configuration utility to enable logging... I will try to trace it with Ethereal today.
Avatar of adlabac

ASKER

I finally found the cause of the problem. Unfortunately there was no right solution, just a workaround.

What I discovered is that there is a problem only if I download the file first! If not, the file is deleted instantly! The same is with Total Commander, as well - If I firstly download (large) file it says that it is deleted OK, but it is still in the folder for some time (usually 20-30 seconds). I even tried to disconnect and reconnect after downloading, bit problem remained.

I am, right not, waiting for folder to be empty before deleting it. If nobody has the some idea, this question should be closed.
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial