2022-10-21 11:16:00 -04:00
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home ](./index.md ) > [bitburner ](./bitburner.md ) > [NS ](./bitburner.ns.md ) > [fileExists ](./bitburner.ns.fileexists.md )
## NS.fileExists() method
Check if a file exists.
2023-02-11 13:18:50 -05:00
**Signature:**
2022-10-21 11:16:00 -04:00
```typescript
fileExists(filename: string, host?: string): boolean;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| filename | string | Filename of file to check. |
2023-05-27 08:34:14 -04:00
| host | string | _(Optional)_ Host of target server. Optional, defaults to the server the script is running on. |
2022-10-21 11:16:00 -04:00
2023-02-11 13:18:50 -05:00
**Returns:**
2022-10-21 11:16:00 -04:00
boolean
True if specified file exists, and false otherwise.
## Remarks
RAM cost: 0.1 GB
2023-10-02 20:14:44 -04:00
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'.
2022-10-21 11:16:00 -04:00
2023-02-14 01:32:01 -05:00
## Example
2022-10-21 11:16:00 -04:00
2023-02-14 01:32:01 -05:00
```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");
2022-10-21 11:16:00 -04:00
// The function call will return true if the current server contains the FTPCrack.exe program, and false otherwise.
ns.fileExists("ftpcrack.exe");
```