# fileCreate (Shared)

> Creates an empty file and opens it for reading and writing. A file that already exists is wiped and made again; missing folders are created.

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

## Syntax

```lua
file|false fileCreate(string path)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `path` | `string` | A path inside the calling resource. |

## Returns

The open file, or `false` if it could not be created.

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`. The file is closed when the resource stops.

## Example

```lua
local file = fileCreate("logs/session.txt")
if file then
    fileWrite(file, "started at ", tostring(getRealTime().timestamp), "\n")
    fileClose(file)
end
```

## See also

- [fileOpen (Shared)](https://wiki.mymp.gg/en/fileOpen.md): Opens a file that already exists, with the position at its start.
- [fileWrite (Shared)](https://wiki.mymp.gg/en/fileWrite.md): Writes one or more texts to a file, at the current position.
- [fileClose (Shared)](https://wiki.mymp.gg/en/fileClose.md): Closes a file, writing what is left, and destroys its element.
