Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Problem with Deleting Empty Folder in Automated Process

You should strip the trailing slash.
Wil

Problem with Deleting Empty Folder in Automated Process

I posted this in the .NET forum, but maybe it should be a support/bug report, as I haven't received any feedback.


This is a great system, and I have done pretty much everything that I have wanted, but struggling on one last point.

I'm using 5.9.3, and am trying to delete an empty directory with an automated process, and not having any luck.

I able to do this with the command prompt FTP and remove the directory with the following commands:

ftp> ls Trinity_00076_20170204_194014
200 Port OK
150 Opening data connection
226 Transfer complete
ftp> rm Trinity_00076_20170204_194014
250 Directory removed
ftp> ls Trinity_00076_20170204_194014
200 Port OK
550 S_dosFsLib_FILE_NOT_FOUND

But when I try to do this with my automated program, using this command: var result = session.RemoveFiles(GetDirectoryName(file));

I get the following results in the XML log file. With the return of result.IsSuccess being false. It deleted the 22 files in the directory, just not the empty folder.

<group name="rm -- &quot;/ata0:1/Echelon/Trinity_00076_20170204_194014/&quot;" start="2017-02-06T18:47:49.269Z">
<rm>
<filename value="/ata0:1/Echelon/Trinity_00076_20170204_194014/" />
<result success="false">
<message>Internal error fz#removedir (0010).</message>
<message>Error deleting file '/ata0:1/Echelon/Trinity_00076_20170204_194014/'.</message>
</result>
</rm>
<failure>
<message>Internal error fz#removedir (0010).</message>
<message>Error deleting file '/ata0:1/Echelon/Trinity_00076_20170204_194014/'.</message>
</failure>
</group>



I tried another way using the below code and the same issues occur. It removes all the data files in the directory, it just doesn't delete the empty directory afterwards and stops the program as it drops the connection. If I run this with deleteWhenSuccessfulFTP = false, the program runs with no problem (but doesn't delete any of the files).

TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
bool deleteWhenSuccessfulFTP = true;

transferResult = session.GetFiles(GetDirectoryName(file), newDirectoryLocal, remove: deleteWhenSuccessfulFTP, options: transferOptions);

Here is the error log:

<rm>
<filename value="/ata0:1/Echelon/Trinity_00083_20170205_094107/Trinity_00083_20170205_094107.srEvtdf" />
<result success="true" />
</rm>
<rm>
<filename value="/ata0:1/Echelon/Trinity_00083_20170205_094107/" />
<result success="false">
<message>Internal error fz#removedir (0010).</message>
<message>Error deleting file '/ata0:1/Echelon/Trinity_00083_20170205_094107/'.</message>
</result>
</rm>
<rm>
<filename value="/ata0:1/Echelon/Trinity_00083_20170205_094107/" />
<result success="false">
<message>Internal error fz#removedir (0010).</message>
<message>Error deleting file '/ata0:1/Echelon/Trinity_00083_20170205_094107/'.</message>
</result>
</rm>
<rm>
<filename value="/ata0:1/Echelon/Trinity_00083_20170205_094107/" />
<result success="false">
<message>Internal error fz#removedir (0010).</message>
<message>Error deleting file '/ata0:1/Echelon/Trinity_00083_20170205_094107/'.</message>
</result>
</rm>
<rm>
<filename value="/ata0:1/Echelon/Trinity_00083_20170205_094107/" />
<result success="false">
<message>Internal error fz#removedir (0010).</message>
<message>Error deleting file '/ata0:1/Echelon/Trinity_00083_20170205_094107/'.</message>
</result>
</rm>
<rm>
<filename value="/ata0:1/Echelon/Trinity_00083_20170205_094107/" />
<result success="false">
<message>Internal error fz#removedir (0010).</message>
<message>Error deleting file '/ata0:1/Echelon/Trinity_00083_20170205_094107/'.</message>
</result>
</rm>
<rm>
<filename value="/ata0:1/Echelon/Trinity_00083_20170205_094107/" />
<result success="false">
<message>Internal error fz#removedir (0010).</message>
<message>Error deleting file '/ata0:1/Echelon/Trinity_00083_20170205_094107/'.</message>
</result>
</rm>
<rm>
<filename value="/ata0:1/Echelon/Trinity_00083_20170205_094107/" />
<result success="false">
<message>Internal error fz#removedir (0010).</message>
<message>Error deleting file '/ata0:1/Echelon/Trinity_00083_20170205_094107/'.</message>
</result>
</rm>


Please let me know if you need anything else. Thanks for any amount of help - Wil