# CFX::SAVE_RESOURCE_FILE

- **Hash:** `0xA09E7E7B`
- **Namespace:** CFX
- **Runtime name (Lua/JS):** `SaveResourceFile`
- **Side:** server (Cfx runtime native)
- **Name status:** official
- **Documentation:** described
- **URL:** https://natives.borderlinerp.com/natives/CFX/SAVE_RESOURCE_FILE

## Signature

```c
BOOL SAVE_RESOURCE_FILE(char* resourceName, char* fileName, char* data, int dataLength);
```

## Parameters

- `resourceName` (`char*`) — The name of the resource.
- `fileName` (`char*`) — The name of the file.
- `data` (`char*`) — The data to write to the file.
- `dataLength` (`int`) — The length of the written data.

## Returns

`BOOL` — A value indicating if the write succeeded.

## Description

*Source: Cfx.re native reference*

Writes the specified data to a file in the specified resource.
Using a length of `-1` will automatically detect the length assuming the data is a C string.

## Usage

### Lua

```lua
local retval = SaveResourceFile(resourceName, fileName, data, dataLength)

-- always available, by hash
local retval = Citizen.InvokeNative(0xa09e7e7b, resourceName, fileName, data, dataLength, Citizen.ReturnResultAnyway())
```

### JavaScript

```js
const retval = SaveResourceFile(resourceName, fileName, data, dataLength);

// by hash
const retval = Citizen.invokeNative('0xa09e7e7b', resourceName, fileName, data, dataLength, Citizen.returnResultAnyway());
```

### C#

```csharp
bool retval = Function.Call<bool>((Hash)0xa09e7e7b, resourceName, fileName, data, dataLength);
```

## See also

- [CFX::LOAD_RESOURCE_FILE](https://natives.borderlinerp.com/natives/CFX/LOAD_RESOURCE_FILE.md) — Reads the contents of a text file in a specified resource.

*Sources: Cfx.re native reference.*
