# 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 %}
