<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [NS](./bitburner.ns.md) &gt; [fileExists](./bitburner.ns.fileexists.md)

## NS.fileExists() method

Check if a file exists.

**Signature:**

```typescript
fileExists(filename: string, host?: string): boolean;
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

filename


</td><td>

string


</td><td>

Filename of file to check.


</td></tr>
<tr><td>

host


</td><td>

string


</td><td>

_(Optional)_ Hostname/IP of target server. Optional, defaults to the server the script is running on.


</td></tr>
</tbody></table>

**Returns:**

boolean

True if specified file exists, and false otherwise.

## Remarks

RAM cost: 0.1 GB

Returns a boolean indicating whether the specified file exists on the target server. The filename for programs is case-insensitive, other file types are case-sensitive. For example, fileExists(“brutessh.exe”) will work fine, even though the actual program is named 'BruteSSH.exe'.

## Example


```js
// The function call will return true if the script named foo.js exists on the foodnstuff server, and false otherwise.
ns.fileExists("foo.js", "foodnstuff");

// The function call will return true if the current server contains the FTPCrack.exe program, and false otherwise.
ns.fileExists("ftpcrack.exe");
```

