Skip to content

Filesystem Activities

Version: 1.0.6  ·  ID: zoan-packages-fs  ·  Author: Zoan Software

The Files (filesystem) package works with files and folders: read and write text files, copy, move, delete, check whether something exists and list a folder’s contents. It is a support package found in almost every automation — to organize downloads, produce output files, move processed documents or read configuration data.

Almost every activity takes a path. You can give it in two ways:

  • Absolute path: C:\reports\output.txt or C:/reports/output.txt. In expressions, the backslash is taken literally: "C:\reports\output.txt" (to end a text with a backslash, write it twice: "C:\reports\\" + name). See Windows paths. Network paths (\\server\share\file.txt) also work if the account the robot runs under has access.
  • Project file with asset(...): for files that travel inside your package (templates, sample data), use asset("data/input.txt"). It resolves the right path on whatever machine runs it. See asset().

Avoid relative paths (output.txt, data\output.txt): they are resolved against the robot’s working folder, which depends on where it starts. Since version 1.0.6, writing, appending, copying or moving with just a file name no longer fails, but a full path makes it clear where the file ends up.

Write File, Append to File, Copy File and Move File create the destination folder (and any intermediate ones) if it does not exist: you don’t need a Create Directory first.

Watch the defaults, which are not the same in every activity:

ActivityDefault overwrite
Write Filetrue — replaces the existing file
Copy File / Move Filefalse — fails if the destination exists

Read File, Write File and Append to File accept an encoding by name. Default "utf-8".

ValueWhen to use it
utf-8Default. When writing, the file starts with the UTF-8 BOM, which Excel and Notepad recognize.
iso-8859-1 (or latin1)Files from legacy Windows systems whose accented characters look wrong as UTF-8.
utf-16 (or unicode), utf-16BE, utf-32Unicode files with 2 or 4 bytes per character.
us-asciiASCII characters only; anything else becomes ?.

When reading, if the file starts with a BOM (UTF-8, UTF-16 or UTF-32), the BOM wins over the given encoding. Other code-page names (such as windows-1252) may not be available and make the activity fail with 'windows-1252' is not a supported encoding name…: use iso-8859-1 instead.

Besides each activity’s own messages, a file operation can fail with an operating-system error (these messages may appear in English or in the Windows language). The most common:

MessageCause and fix
The process cannot access the file '…' because it is being used by another process.Another program has the file open (typically an open Excel workbook). Close it first, or retry with Retry and a delay.
Access to the path '…' is denied.The robot’s account has no permission on the file or folder, or the file is read-only.
Could not find a part of the path '…'.A folder in the path does not exist (for example, a disconnected network drive).
ActivityTypeOutputWhat it does
Read Fileread-filestringReads the content of a text file
Write Filewrite-filestringWrites text to a file (creates or replaces it)
Append to Fileappend-filestringAppends text to the end of a file
ActivityTypeOutputWhat it does
File Existsfile-existsboolDoes the file exist?
Copy Filecopy-filestringCopies a file to another path
Move Filemove-filestringMoves or renames a file
Delete Filedelete-file—Deletes a file
ActivityTypeOutputWhat it does
Create Directorycreate-directorystringCreates a folder (and any missing ones in the path)
List Fileslist-filesListLists the files/folders in a directory

Process each downloaded file and archive it:

List Files path = "C:/downloads" pattern = "*.xlsx" → output: files
For Each items = files itemVariable = path
└─ activities:
... process the file ...
Move File source = path destination = pathJoin("C:/processed", fileName(path))