---
title: "writeDirectoryContents(archiveFrom:path:keySet:selectUsing:flags:threadCount:)"
framework: applearchive
role: symbol
role_heading: Instance Method
path: "applearchive/archivestream/writedirectorycontents(archivefrom:path:keyset:selectusing:flags:threadcount:)"
---

# writeDirectoryContents(archiveFrom:path:keySet:selectUsing:flags:threadCount:)

Writes all entries from a directory to the archive stream.

## Declaration

```swift
func writeDirectoryContents(archiveFrom directory: FilePath, path: FilePath? = nil, keySet: ArchiveHeader.FieldKeySet, selectUsing filter: ArchiveHeader.EntryFilter? = nil, flags: ArchiveFlags = [], threadCount: Int = 0) throws
```

## Parameters

- `directory`: The base directory that the operation scans and archives.
- `path`: An optional subdirectory to restrict the scan.
- `keySet`: The fields to include for each entry.
- `filter`: A closure that’s called for each entry that’s received by the stream.
- `flags`: Flags that control the behavior of the operation.
- `threadCount`: The number of worker threads that the operation uses, set to 0 for default.
