File Handler
File Handler
The file handler (ExternalTypes.File) allows CDP properties to reference external files, providing metadata about the file and enabling file operations. This is useful for:
- Linking configuration files to CDP properties
- Managing binary or large text content
- File metadata access (size, content type, modification time)
- File operations (rename, delete) through property value changes
- Manipulating the file (i.e., copying, removing, viewing content) via CDP Studio TypeHint="File" delegate
Features:
- Automatic content type detection
- File size and metadata reporting
- File existence validation
- Safe file operations with error handling
- File path can contain environment variables and OS-specific slices as described in External Type Path Resolving.
File handler has one configurable property. It can be set globally under the External Type Provider configuration, or per-node using the ExternalType="File;..." model attribute.
Note: The File handler is currently not added to the CDP.ExternalTypesProvider configuration by default. To use it, the handler needs to be added to the CDP.ExternalTypesProvider configuration first (from Resource tree). Also, currently, the File handler supports file manipulation operations (i.e., copying, removing, viewing content) only in offline mode (in CDP Studio Configure Mode). Online mode support for these operations will be added in future releases.
Configuration Properties:
| Property | Type | Default | Description |
|---|---|---|---|
| Location | string | Path (relative to application working directory or absolute), where the file will be located. The path can include environment variables and OS-specific slices as described in External Type Path Resolving. Empty means the application working directory will be used. |
Metadata Keys Exposed by The File Handler:
| Key | Description |
|---|---|
| ExternalType | Always "File" |
| Name | Current filename (if file exists) |
| ContentType | MIME content type of the file |
| Length | File size in bytes |
| Error | Error message if file operation failed |
Example Usage:
<Attribute Name="simulationmodelfile.fmu" Type="string" ExternalType="File" TypeHint="File"/>
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.