# VerifyDirectory
Verifies all files in a directory. This approach combines [UseUniqueDirectory](/docs/naming.md#useuniquedirectory) with a target per file, to snapshot test all files in a directory.
```cs
[Fact]
public Task WithDirectory() =>
VerifyDirectory(directoryToVerify);
```
snippet source | anchor
## Filtering
```cs
[Fact]
public Task WithDirectoryFiltered() =>
VerifyDirectory(
directoryToVerify,
include: filePath => filePath.Contains("Doc"),
pattern: "*.txt",
options: new()
{
RecurseSubdirectories = false
});
```
snippet source | anchor
## Optional Info
An optional `info` parameter can be supplied to add more context to the test. The instance passed will be json serialized.
```cs
[Fact]
public Task VerifyDirectoryWithInfo() =>
VerifyDirectory(
directoryToVerify,
info: "the info");
```
snippet source | anchor
## FileScrubber
`VerifyDirectory` has an optional parameter `fileScrubber` that allows file specific scrubbing:
```cs
[Fact]
public Task VerifyDirectoryWithFileScrubber() =>
VerifyDirectory(
directoryToVerify,
fileScrubber: (path, builder) =>
{
if (Path.GetFileName(path) == "TextDoc.txt")
{
builder.Clear();
builder.Append("New text");
}
});
```
snippet source | anchor
This applies to files where the extensions is a known text file as defined by [FileExtensions.IsText](https://github.com/VerifyTests/EmptyFiles#istext).
## Files with no extension
Any files in the target directory that have no extension will have `.noextension` added to the resulting `.verified` file. This is to avoid `.verified` being treated as the extension of that file.
These files are treated as unknown binaries by default. Given the lack of an extension, no diff tool will be launched.
Files with no extension can optionally be treated as text, with the associated diff tool being launched. This is done by using the [AddTextFileConvention](https://github.com/VerifyTests/EmptyFiles?tab=readme-ov-file#addtextfileconvention) of EmptyFiles:
```cs
[ModuleInitializer]
public static void InitTextFileConvention() =>
FileExtensions.AddTextFileConvention(
path =>
{
var name = Path.GetFileName(path);
return name.Equals("TextDocWithoutExtension", StringComparison.OrdinalIgnoreCase);
});
```
snippet source | anchor