FileDownloaderActivity - File Synchronization
Overview
FileDownloaderActivity is a file synchronization node used to synchronize files from SMB shared folders to local directories. This node supports authentication for remote shared folders, file matching filtering, synchronization mode selection, and source file deletion.
Basic Information
| Property | Value |
|---|---|
| Display Name | File Synchronization |
| Class Name | FileDownloaderActivity |
| Namespace | CMS.Plugin.FlowManagement.Domain.FlowBusiness.Activitys |
| Base Class | ActionActivity |
| Category | File Operations |
| Visibility | Visible (Visible = true) |
| Sort | 20 |
Configuration Description
SMB Configuration
| Property Name | Display Name | Type | Default | Description |
|---|---|---|---|---|
| SoruceDirectoryPath | Source Directory | string | null | Remote shared folder path, directory to sync |
| UserName | Username | string | null | SMB share access username |
| Password | Password | string | null | SMB share access password |
| SearchPattern | Match Pattern | string | "*.csv" | File match pattern, supports wildcards |
| SearchOption | Search Option | SearchOption | TopDirectoryOnly | Search scope: Top directory only or include subdirectories |
| TargetDirectoryPath | Target Directory | string | "FileDownloaderTempFiles" | Local target directory, supports absolute or relative paths |
| DeleteSourceFile | Delete Source File | bool | true | Whether to delete source files after synchronization |
| SynchronousMode | File Sync Mode | FileSynchronousMode | Skip | Handling method when target file exists |
| SavePathsContext | Process Context | string | null | Context variable name to store synchronized file paths collection |
Search Option (SearchOption)
| Enum Value | Description |
|---|---|
| TopDirectoryOnly | Search only the top directory |
| AllDirectories | Search all subdirectories |
File Sync Mode (FileSynchronousMode)
| Enum Value | Description |
|---|---|
| Skip | Skip existing files |
| Rename | Rename new files (add sequence suffix) |
Process Context
Output Variables
| Variable Name | Type | Description |
|---|---|---|
{SavePathsContext} | List<string> | Collection of synchronized target file paths (Variable name specified by configuration) |
Business Logic
Execution Flow
┌ ─────────────────────────────────────────────────────────────┐
│ FileDownloaderActivity │
├─────────────────────────────────────────────────────────────┤
│ 1. Determine Source Directory Type │
│ ├─ Local path (e.g. C:\...) → Direct access │
│ └─ Network path (e.g. \\server\...) → Establish SMB conn│
├─────────────────────────────────────────────────────────────┤
│ 2. Establish SMB Connection (if needed) │
│ └─ Use net use command to connect share │
├─────────────────────────────────────────────────────────────┤
│ 3. Scan Source Directory │
│ └─ Find files based on SearchPattern and SearchOption │
├─────────────────────────────────────────────────────────────┤
│ 4. Sync Files │
│ ├─ Check if target file exists │
│ ├─ Handle conflict based on SynchronousMode │
│ ├─ Copy file to target directory │
│ └─ Delete source file (if configured) │
├─────────────────────────────────────────────────────────────┤
│ 5. Output Result │
│ └─ Store synced file paths to process context │
└─────────────────────────────────────────────────────────────┘
Path Handling
- Local Path Check: Checks if the second character of the path is
:(e.g.,C:\). - Relative Path Conversion: Non-absolute paths are automatically converted to absolute paths relative to the application directory.
- Auto Create Directory: Automatically creates the target directory if it does not exist.
File Conflict Handling
| Mode | Handling Method |
|---|---|
| Skip | Skip synchronization, keep original file |
| Rename | Add sequence number to filename, e.g., file-1.csv, file-2.csv |
Usage Examples
Basic Configuration
{
"Name": "Sync CSV Files",
"Type": "FileDownloaderActivity",
"SoruceDirectoryPath": "\\\\192.168.1.100\\share\\data",
"UserName": "admin",
"Password": "password123",
"SearchPattern": "*.csv",
"TargetDirectoryPath": "SyncFiles",
"DeleteSourceFile": true,
"SynchronousMode": "Skip",
"SavePathsContext": "SyncedFiles"
}
Sync All Subdirectories
{
"Name": "Sync All Files",
"Type": "FileDownloaderActivity",
"SoruceDirectoryPath": "\\\\fileserver\\backup",
"UserName": "backup_user",
"Password": "backup_pwd",
"SearchPattern": "*.*",
"SearchOption": "AllDirectories",
"TargetDirectoryPath": "D:\\LocalBackup",
"DeleteSourceFile": false,
"SynchronousMode": "Rename"
}
Local Directory Sync
{
"Name": "Local File Sync",
"Type": "FileDownloaderActivity",
"SoruceDirectoryPath": "D:\\SourceData",
"SearchPattern": "*.xml",
"TargetDirectoryPath": "ProcessedData",
"DeleteSourceFile": true,
"SavePathsContext": "ProcessedFiles"
}
Coordination with Subsequent Processing
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│FileDownloaderActivity│──▶│ CsvReadActivity │──▶│ DataFilterActivity│
│ Sync CSV Files │ │ Read Synced Files│ │ Process Data │
│ SavePathsContext: │ │ │ │ │
│ "SyncedFiles" │ │ │ │ │
└──────────────────┘ └──────────────────┘ └──────────────────┘
Notes
- Network Access Permissions: Ensure the running account has permission to access the SMB share.
- Firewall Settings: Ensure SMB port (445) is not blocked by the firewall.
- Credential Security:
- Avoid storing passwords in plain text in configuration.
- Recommended to use configuration encryption or credential management.
- Disk Space: Ensure the target directory has sufficient disk space.
- File Locking:
- Copy may fail if the source file is in use.
- If deleting the source file fails due to being in use, an exception is recorded but the process is not interrupted.
- Path Format:
- Network paths use UNC format:
\\server\share\folder - Local paths use standard format:
C:\folderor relative paths.
- Network paths use UNC format:
- Performance Considerations:
- Pay attention to network bandwidth when syncing large numbers of files.
- Recommended to perform bulk synchronization during off-peak hours.
Error Handling
| Error Scenario | Handling Method |
|---|---|
| SMB Connection Failed | Throw exception, record error info |
| File Copy Failed | Record exception, continue processing next file |
| Source File Delete Failed | Record exception, does not affect sync result |
| Target Directory Create Failed | Throw exception |
Related Nodes
- FileCopyActivity - File Copy Node
- FileMoveActivity - File Move Node
- FileReadActivity - File Read Node
- CsvReadActivity - CSV Read Node
- DirectoryCopyActivity - Directory Copy Node
Last updated: 2025-11-28