# fileCopy (Shared)

> Copies a file, possibly from another resource, into the calling resource. Folders missing at the destination are created.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Shared
- **Category**: Files
- **URL**: https://wiki.mymp.gg/en/fileCopy

## Syntax

```lua
bool fileCopy(string from, string to [, bool overwrite = false])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `from` | `string` | The file to copy. A path inside the calling resource, or `@resource/path` for another resource's file. |
| `to` | `string` | Where to copy it. A path inside the calling resource. |
| `overwrite` | `bool` | Whether a file already at the destination is replaced. *(default: `false`)* |

## Returns

`true` if it worked; `false` if the source is not a file or the destination exists and `overwrite` is off.

A path may not contain `..`, `\` or `:`, nor start with `/`. Another resource's files can only be read; an invalid path logs a warning and the function returns `false`.

## Example

```lua
fileCopy("@defaults/settings.json", "settings.json")
```

## See also

- [fileRename (Shared)](https://wiki.mymp.gg/en/fileRename.md): Renames or moves a file within the calling resource. Folders missing at the destination are created.
- [fileDelete (Shared)](https://wiki.mymp.gg/en/fileDelete.md): Deletes a file of the calling resource.
