# FileUtil

## MoveToChildDirectory

This handy helper takes a file and a child directory and does the lookups, directory creation, and move operation

{% code overflow="wrap" %}

```csharp
//Moves item to c:\temp\processed\item.txt
FileUtil.MoveToChildDirectory(@"C:\temp\item.txt", "processed", overwrite: true, createDirectory: true);
```

{% endcode %}

## CreateDirectoryIfNotExists

Verify if a directory exists for a given item

{% code overflow="wrap" %}

```csharp
//Verifies directory c:\temp\ exists
FileUtil.CreateDirectoryIfNotExists(@"C:\temp\item.txt");
```

{% endcode %}

## CleanFilenameWithPath

Clean a filename with the OS invalid file characters.

{% code overflow="wrap" %}

```csharp
//produces: C:\temp\it-em-.txt
var valid = FileUtil.CleanFilenameWithPath(@"C:\temp\it|em|.txt");
```

{% endcode %}


---

# Agent Instructions: 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:

```
GET https://docs.perigee.software/core-modules/utility-classes/fileutil.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
