+1 vote

I am needing a method of removing all files in a folder except for a specific file (my.config) in preparation for uploading files to the same location.
I could easily just delete the folder containing the files, but I do not want to remove or overwrite the config file.

Any help on the code is greatly appreciated.

by (350 points)

1 Answer

0 votes

I think the easiest way would be to use Ftp.DeleteFiles method with RemoteSearchOptions parameter:

Ftp.DeleteFiles(RemoteSearchOptions.UseLambdaMatch( 
    (RemoteSearchItem item) => { return false; } )

You need to provide your own callback that would return false for 'my.config' name and true for everything else.

by (300k points)
...