> For the complete documentation index, see [llms.txt](https://support.powerio.com/hub/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.powerio.com/hub/codesys-hvac/hvac-library/functionblocks/fileviewer/listfiles.md).

# ListFiles

## `ListFiles` (FB)

FUNCTION\_BLOCK ListFiles EXTENDS CBML.ETrig

### ListFiles

Der `ListFiles` Function-Block ermöglicht das Auflisten von Dateien in einem Verzeichnis. Dieser Function-Block bietet Konfigurationsoptionen für das Verzeichnis, Sortierkriterien und einen Filter für Dateinamen.

### Darstellung

<figure><img src="https://879424349-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQR4vCFzt6ixgsqlR3pdR%2Fuploads%2FF1lynplpVWo49L95Qpwf%2FListFiles.png?alt=media&amp;token=ae326f0f-7814-45e1-a585-793e9d54d854" alt=""><figcaption></figcaption></figure>

## Verwendung

Der Block wird verwendet, um Dateien in einem spezifizierten Verzeichnis zu lesen, zu filtern und Informationen zu den gefundenen Dateien und Verzeichnissen zurückzugeben.

## Eingänge

* **sDirectoryName:** STRING(254) Der Pfad des Verzeichnisses, das durchsucht werden soll. Standardmäßig ist dies ‘./’.
* **eSortBy:** SORT\_BY Das Kriterium, nach dem die Dateien sortiert werden sollen. Standardmäßig ist dies nach dem letzten Änderungsdatum.
* **sContains:** STRING Ein Filter, der angibt, welche Zeichenfolge die Dateinamen enthalten müssen. Standardmäßig ist dies ‘.csv’.
* **itfFileList:** COL.ISortedList2 Eine Schnittstelle zu einer sortierten Liste, in die die gefilterten Dateieinträge eingefügt werden.

## Ausgänge

* **udiFilesInDirectory:** UDINT Die Gesamtanzahl der Dateien im Verzeichnis.
* **udiDirectoriesInDirectory:** UDINT Die Anzahl der Verzeichnisse im Verzeichnis.
* **udiFilteredFilesInDirectory:** UDINT Die Anzahl der Dateien, die den Filterkriterien entsprechen.

## Verarbeitungslogik

1. Der FB öffnet das Verzeichnis asynchron und liest die Dateiinformationen.
2. Für jede Datei im Verzeichnis wird geprüft, ob sie die Filterkriterien erfüllt.
3. Gefilterte Dateien werden in die übergebene sortierte Liste eingefügt.
4. Der FB gibt die Anzahl der Dateien, Verzeichnisse und gefilterten Dateien zurück.

InOut:

| Scope  | Name                          | Type               | Initial                     | Inherited from |
| ------ | ----------------------------- | ------------------ | --------------------------- | -------------- |
| Input  | `xExecute`                    | `BOOL`             |                             | ETrig          |
| Output | `xDone`                       | `BOOL`             |                             | ETrig          |
| Output | `xBusy`                       | `BOOL`             |                             | ETrig          |
| Output | `xError`                      | `BOOL`             |                             | ETrig          |
| Input  | `sDirectoryName`              | `STRING(254)`      | ‘./’                        |                |
| Input  | `eSortBy`                     | SORT\_BY           | SORT\_BY.LAST\_MODIFICATION |                |
| Input  | `sContains`                   | `STRING`           | ‘.csv’                      |                |
| Input  | `itfFileList`                 | `COL.ISortedList2` |                             |                |
| Output | `udiFilesInDirectory`         | `UDINT`            |                             |                |
| Output | `udiDirectoriesInDirectory`   | `UDINT`            |                             |                |
| Output | `udiFilteredFilesInDirectory` | `UDINT`            |                             |                |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://support.powerio.com/hub/codesys-hvac/hvac-library/functionblocks/fileviewer/listfiles.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
