> 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="/files/Ai04TEy0BSkBNhv2heG9" 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
