File Resource
Synopsis
Manages files on the local filesystem. Supports creating files with specified content and removing files. Works on Windows, Linux, and macOS.
Type
Capabilities
- Get
- Set
- Delete
Properties
path
Path to the file.
content
Content of the file.
_exist
Whether the file should exist.
Examples
Example 1 — Get a file
Example 2 — Create a file with content
Example 3 — Delete a file
Example 4 — Configuration document
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Application config file
type: OpenDsc.FileSystem/File
properties:
path: /opt/myapp/config.json
content: |
{
"logLevel": "Information",
"port": 8080
}
Exit codes
| Code | Description |
|---|---|
| 0 | Success |
| 1 | Error |
| 2 | Invalid JSON |
| 3 | Access denied |
| 4 | Invalid argument |
| 5 | IO error |