# fileClose (Shared)

> Closes a file, writing what is left, and destroys its element.

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

## Syntax

```lua
bool fileClose(file file)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `file` | `file` | A file opened by `fileOpen` or `fileCreate`. |

## Returns

`true`.

## Example

```lua
local file = fileOpen("notes.txt")
if file then
    fileWrite(file, "hello")
    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.
- [fileCreate (Shared)](https://wiki.mymp.gg/en/fileCreate.md): 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.
- [fileFlush (Shared)](https://wiki.mymp.gg/en/fileFlush.md): Writes to disk what was written to the file and is still in memory.
