---
name: "fileExists"
type: command
status: ok
groups: ["Program Flow"]
arma3_since: "2.02"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/fileExists
revid: 352073
updated: 2024-02-01T23:24:41Z
---

# fileExists

*Command · Program Flow · Arma 3 v2.02*

## Description

Checks if file on given path exists. Uses same path resolve code as [loadFile](../commands/loadFile.md).

> [!NOTE]
> Absolute paths are not supported, such as those generated using [getMissionPath](../commands/getMissionPath.md). Attempting to check an absolute path will result in this error in RPT logs:
> `Invalid path (only relative paths supported): 'C:\...'`

## Syntax

```sqf
fileExists path
```

**Parameters:**

- `path`: [String](../topics/String.md) - path to file

**Returns:** [Boolean](../topics/Boolean.md) - [true](../commands/true.md) if it exists, otherwise [false](../commands/false.md)

## Examples

### Example 1

```sqf
fileExists "\a3\mySuperPath\bestFileEver.paa"; // returns false
```

### Example 2

```sqf
private _path = "a3\functions_f_mp_mark\revive\_addaction_revive.inc";
if (fileExists _path) then { loadFile _path } else { diag_log format ["File (%1) does not exist!", _path] };
```

### Example 3

```sqf
// Sometimes it might be better to check if a file exists instead of checking if path is empty ("")
private _class = "ModuleObjectiveRaceFinish_F";
private _picture = getText (configFile >> "CfgVehicles" >> _class >> "editorPreview");
if !(fileExists _picture) then { _picture = getText (configFile >> "CfgVehicles" >> _class >> "portrait") };
if !(fileExists _picture) then { _picture = getText (configFile >> "CfgVehicles" >> _class >> "icon") };
if !(fileExists _picture) then { _picture = getText (configFile >> "CfgVehicles" >> _class >> "picture") };
if !(fileExists _picture) then { systemChat "No valid picture found!" } else { systemChat _picture };
```

## See also

[loadFile](../commands/loadFile.md) · [preprocessFile](../commands/preprocessFile.md) · [preprocessFileLineNumbers](../commands/preprocessFileLineNumbers.md)

## Community notes

**Leopard20** — 2022-01-01

Returns [true](../commands/true.md) for empty strings: `fileExists ""; // true`

<sub>Source: [BI Community Wiki — fileExists](https://community.bistudio.com/wiki/fileExists) (revision 352073).</sub>
