EmptyDirectory: New API to leave top level dir intact
New function overload (Wiki API will need update) to allow users of DeleteDirectory to optionally make this function leave the top level directory intact.
Using this will prevent use of any highly optimised server side RMDIR functionality on the uppermost level, but that's the price.
Usage:
/// <summary>
/// Deletes the specified directory and all its contents.
/// </summary>
/// <param name="path">The full or relative path of the directory to delete</param>
/// <param name="options">Useful to delete hidden files or dot-files.</param>
/// <param name="deleteFinalDir">Delete the top level dir too</param>
public void DeleteDirectory(string path, FtpListOption options, bool deleteFinalDir = true)
The default for deleteFinalDir is true, which is the normal behaviour right now.
Looks fantastic! Thanks again for your wonderful work. Added some comments.
I will rebase so we can see the net changes
Yes, the rebase removed all the reference to the serverhandlers and so on, because now with the new API function, things are a whole lot less complicated (instead of the insane overloading). Thanks @robinrodricks
If you want this to be a separate .cs, can you do that?
I would have merged this PR and changed it myself, but since its a draft I cannot. (EDIT: I did it!)
Anyway, can you please rename the API to EmptyDirectory as DeleteDirectoryContents is much too long, and I don't bother much with API discoverability. I prefer short names ("TransferFile" rather than "FXPTransferFile" and so on). I like ClearDirectory too, however it is very similar in meaning to DeleteDirectory so I can see some users getting confused about it.
As you can see I try to use the shortest name possible, ideally in this format <verb> <term>
- DirectoryExists
- CreateDirectory
- DeleteDirectory
- EmptyDirectory
- MoveDirectory
Oh wait I got it.
I'll change it, thanks a lot for this.
I have just tested it, and it still works. Sorry I forgot about adding the interface definitions. I shall do the Wiki addition, in the next few days and I ask you to review that then...
Released!
https://www.nuget.org/packages/FluentFTP/41.0.0