2021-10-30 12:34:14 -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
2021-11-03 18:16:10 -04:00
Check if a file exists.
2021-10-30 12:34:14 -04:00
< b > Signature:< / b >
```typescript
2021-10-30 15:46:34 -04:00
fileExists(filename: string, host?: string): boolean;
2021-10-30 12:34:14 -04:00
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| filename | string | Filename of file to check. |
2021-11-03 00:27:21 -04:00
| host | string | Host of target server. This is optional. If it is not specified then the function will use the current server as the target server. |
2021-10-30 12:34:14 -04:00
< b > Returns:< / b >
boolean
True if specified file exists, and false otherwise.
## Remarks
2021-10-30 15:46:34 -04:00
RAM cost: 0.1 GB
2021-10-30 12:34:14 -04:00
2021-11-03 18:16:10 -04:00
Returns a boolean indicating whether the specified file exists on the target server. The filename for scripts is case-sensitive, but for other types of files it is not. For example, fileExists(“brutessh.exe”) will work fine, even though the actual program is named 'BruteSSH.exe'.
If the hostname/ip argument is omitted, then the function will search through the current server (the server running the script that calls this function) for the file.
2021-10-30 12:34:14 -04:00
## Example 1
2021-10-30 15:46:34 -04:00
```ts
2022-01-08 13:25:06 -05:00
// NS1:
2021-10-30 12:34:14 -04:00
//The function call will return true if the script named foo.script exists on the foodnstuff server, and false otherwise.
fileExists("foo.script", "foodnstuff");
2022-01-08 13:25:06 -05:00
//The function call will return true if the current server contains the FTPCrack.exe program, and false otherwise.
fileExists("ftpcrack.exe");
2021-10-30 12:34:14 -04:00
```
2022-01-08 13:25:06 -05:00
\*
2021-10-30 12:34:14 -04:00
## Example 2
2021-10-30 15:46:34 -04:00
```ts
2022-01-08 13:25:06 -05:00
// NS2:
// The function call will return true if the script named foo.script exists on the foodnstuff server, and false otherwise.
ns.fileExists("foo.script", "foodnstuff");
// The function call will return true if the current server contains the FTPCrack.exe program, and false otherwise.
ns.fileExists("ftpcrack.exe");
2021-10-30 12:34:14 -04:00
```