How to exclude a complete folder tree when uploading.

0 votes
asked Jul 29, 2015 by Uwe Keim (700 points)

I want to Upload the folder "C:\MyFolder" and all files and subfolders via FTP.

Except one single folder "C:\MyFolder\Ignore" with all its content.

When using a FileSet I tried serveral exclude pattern and none matched.

var fs = new FileSet(@"C:\MyFolder\");
fs.Include(@"*");

// This didn't work:
fs.Exclude(@"**/MyFolder/Ignore/**");

// This didn't work, too:
fs.Exclude(@"C:\MyFolder\Ignore");

My questions:

  • What is the correct syntax to exclude a full subtree?
  • Are exclude patterns case-sensitive? If yes, how to make them case-insensitive?
Applies to: Rebex FTP/SSL

1 Answer

+1 vote
answered Jul 29, 2015 by Tomas Knopp (58,580 points)
selected Jul 29, 2015 by Uwe Keim
 
Best answer

A] Exclude and Include methods do not support full paths. They only accept paths and patterns relative to the basePath of the FileSet (in your case, relative to @C:\MyFolder"). So in your case to Exclude the "C:\MyFolder\Ignore" folder completely, just write:

var fs = new FileSet(@"C:\MyFolder");
fs.Include("*");

fs.Exclude("Ignore");

B] the patterns follow the case sensitivity of the OS that your program runs on. So if you are on Windows systems, the patterns are not case-sensitive, whereas on Linux, Unix, OSX, iOS, etc the patterns are case sensitive.

commented Jul 29, 2015 by Uwe Keim (700 points)
Awesome, thanks a lot, Tomas!
commented Jul 29, 2015 by Uwe Keim (700 points)
If I have another folder, say "Ignore-Dont", that starts the same as "Ignore", it still would be included, right?
commented Jul 29, 2015 by Tomas Knopp (58,580 points)
Yes, it will be included.
commented Jul 29, 2015 by Tomas Knopp (58,580 points)
Thank you for your feedback. I have improved the xml doc of the FileSet.Include and Exclude method.  With the next release of our web, we'll also impove the features page at https://www.rebex.net/ftp-ssl.net/features/multiple-files-operations.aspx#fileset
...