-
-
Notifications
You must be signed in to change notification settings - Fork 659
Rules
Tip: For detailed documentation refer to the IntelliSense tips that appear when you call a given API method.
These methods currently support the rule engine.
-
UploadDirectory()
-
DownloadDirectory()
Rules allow you to declaratively specify which files and folders should be copied and which should be skipped. There are rules that let you filter on file extension (eg: upload only PDF files) or file size (eg: upload files smaller than 100 MB) and various other parameters.
Only files that pass all the rules are copied from the source to the target. If you are using Mirror mode then the files that fail the rules will be also deleted from the target.
The rules that are supported are listed here:
Rule Class | Parameters | Description |
---|---|---|
FtpFileExtensionRule | extensions |
Only transfer files of a certain extension, or blacklist files of a certain extension. |
FtpFileNameRule | names |
Only transfer files of a certain name, or blacklist files of a certain name |
FtpFolderNameRule | names |
Only transfer folders of a certain name, or blacklist folders of a certain name |
FtpSizeRule | ruleOperator, x, y |
Only transfer files within a certain size, or blacklist files above/below a certain size |
FtpFileNameRegexRule | regexPatterns |
Only transfer files whose names match the given regular expression(s), or blacklist files that match |
FtpFolderNameRegexRule | regexPatterns |
Only transfer folders whose names match the given regular expression(s), or blacklist folders that match |
Declare the rules and then call DownloadDirectory
or UploadDirectory
with those rules:
var rules = new List<FtpRule>{
new FtpFileExtensionRule(true, new List<string>{ "pdf" }), // only allow PDF files
new FtpSizeRule(FtpOperator.LessThan, 1000000000) // only allow files <1 GB
};
client.DownloadDirectory(@"C:\website\attachments\", @"/public_html/attachments",
FtpFolderSyncMode.Update, FtpLocalExists.Skip, FtpVerify.None, rules);
Declare the rules and then call DownloadDirectory
or UploadDirectory
with those rules:
// this uses the pre-defined blacklist that skips directories named `.git`, `.svn`, `node_modules` etc
var rules = new List<FtpRule>{
new FtpFolderNameRule(false, FtpFolderNameRule.CommonBlacklistedFolders),
};
client.DownloadDirectory(@"C:\project\src\", @"/project/src",
FtpFolderSyncMode.Update, FtpLocalExists.Skip, FtpVerify.None, rules);
- Auto Connection
- Auto Reconnection
- FTP(S) Connection
- FTP(S) Connection using GnuTLS
- FTPS Proxies
- Custom Servers
- Custom Commands
- v40 Migration Guide