# CreateFile

- Module: [Aspire.Hosting](/reference/api/go/aspire.hosting.md)
- Version: `17.0.0`
- Kind: `method`
- Defined on: [`ContainerFileSystemCallbackContext`](/reference/api/go/aspire.hosting/containerfilesystemcallbackcontext.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

Creates a container file entry with inline contents or a host source path.

## Definition

```go
func (ContainerFileSystemCallbackContext) CreateFile(
    name string,
    options ...*CreateFileOptions,
) ContainerFileSystemItem
```

## Parameters

- `name` (`string`) -- The simple file name (no path separators).
- `options` (`...*CreateFileOptions`) -- optional settings, see [Options](#options)

## Options

Optional parameters are passed in a trailing `options ...*CreateFileOptions` argument.

- `Contents` (`*string`) -- The inline UTF-8 contents of the file. Mutually exclusive with `sourcePath`.
- `SourcePath` (`*string`) -- An absolute path to a file on the host to copy. Mutually exclusive with `contents`.
- `Owner` (`*float64`) -- The owner UID, or `null` to inherit.
- `Group` (`*float64`) -- The group GID, or `null` to inherit.
- `Mode` (`*float64`) -- The Unix file mode as an integer (for example `0o644`), or `null` to inherit.
- `ContinueOnError` (`*bool`) -- Whether to ignore errors creating this file.

## Returns

[`ContainerFileSystemItem`](/reference/api/go/aspire.hosting/containerfilesystemitem.md) -- The created file entry.

Returns a handle; failures surface later via `Err()`.

## Applies to

- [`ContainerFileSystemCallbackContext`](/reference/api/go/aspire.hosting/containerfilesystemcallbackcontext.md)
