# ContainerDirectory Methods

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [ContainerDirectory](/reference/api/csharp/aspire.hosting/containerdirectory.md)
- Kind: `Methods`
- Members: `1`

Represents a directory in the container file system.

## GetFileSystemItemsFromPath(string, string, SearchOption, Action<ContainerFileSystemItem>)

- Name: `GetFileSystemItemsFromPath(string, string, SearchOption, Action<ContainerFileSystemItem>)`
- Modifiers: `static`
- Returns: [IEnumerable<ContainerFileSystemItem>](/reference/api/csharp/aspire.hosting/containerfilesystemitem.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/ContainerFileSystemCallbackAnnotation.cs#L135-L222)

Enumerates files from a specified directory and converts them to [ContainerFile](/reference/api/csharp/aspire.hosting/containerfile.md) objects.

```csharp
public sealed class ContainerDirectory
{
    public static IEnumerable<ContainerFileSystemItem> GetFileSystemItemsFromPath(
        string path,
        string searchPattern = "*",
        SearchOption searchOptions = SearchOption.TopDirectoryOnly,
        Action<ContainerFileSystemItem>? updateItem = null)
    {
        // ...
    }
}
```

## Parameters

- `path` (`string`)
  The directory path to enumerate files from.
- `searchPattern` (`string`) `optional`
  The search pattern to control the items matched. Defaults to *.
- `searchOptions` (`SearchOption`) `optional`
  The search options to control the items matched. Defaults to SearchOption.TopDirectoryOnly.
- `updateItem` (`Action<ContainerFileSystemItem>`) `optional`
  An optional function to update each [ContainerFileSystemItem](/reference/api/csharp/aspire.hosting/containerfilesystemitem.md) before returning it. This can be used to set additional properties like Owner, Group, or Mode.

## Returns

[IEnumerable<ContainerFileSystemItem>](/reference/api/csharp/aspire.hosting/containerfilesystemitem.md) -- An enumerable collection of [ContainerFileSystemItem](/reference/api/csharp/aspire.hosting/containerfilesystemitem.md) objects.

## Exceptions

- `DirectoryNotFoundException` -- Thrown when the specified path does not exist.
