> ## Documentation Index
> Fetch the complete documentation index at: https://docs.simular.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# File

> A file on a []'s filesystem.

A file on a \[`Machine`]'s filesystem.

Obtain via \[`Machine.file`]. The handle stays bound to the machine it
came from: paths are meaningful only on that machine, and all operations
run there. Content access is text-oriented (\[`File.read`] trims,
\[`File.write`] takes strings).

## Constructor

```typescript
File(): File
```

### Returns

`File`

## Methods

### copyTo()

```typescript
copyTo(dest: string): File
```

Copies the file to `dest` on the same machine, returning a handle
to the copy. Fails when `dest` already exists.

Local: an absolute `dest` is used as-is. A relative `dest` is joined
to the `SimularFiles` root (`..` is kept — this is a default base,
not a sandbox).
Android: `dest` must be absolute.

#### Parameters

<ResponseField name={"dest"} type={"string"} required />

#### Returns

`File`

### delete()

```typescript
delete(): void
```

Deletes the file, invalidating the handle.

### extension()

```typescript
extension(): null | string
```

The file extension, if any.

#### Returns

`null | string`

### isReadonly()

```typescript
isReadonly(): boolean
```

Whether the file is read-only.

#### Returns

`boolean`

### modified()

```typescript
modified(): number
```

The last modification time as milliseconds since the Unix epoch.

#### Returns

`number`

### moveTo()

```typescript
moveTo(dest: string): void
```

Moves the file to `dest` on the same machine. Fails when `dest`
already exists. Path resolution as in \[`File.copyTo`].

#### Parameters

<ResponseField name={"dest"} type={"string"} required />

### name()

```typescript
name(): string
```

The file name (last component of the path).

#### Returns

`string`

### path()

```typescript
path(): string
```

The file's path on its machine, as a string.

#### Returns

`string`

### read()

```typescript
read(): string
```

Reads the file and returns its trimmed contents.

#### Returns

`string`

### rename()

```typescript
rename(newName: string): void
```

Renames the file in place (same parent directory). `newName` must
be a single filename component.

#### Parameters

<ResponseField name={"newName"} type={"string"} required />

### size()

```typescript
size(): number
```

The file size in bytes.

#### Returns

`number`

### write()

```typescript
write(content: string, append: boolean): void
```

Writes content to the file, overwriting it — or appending, with a
newline inserted first when the file already has content. Parent
directories are created if needed.

#### Parameters

<ResponseField name={"content"} type={"string"} required />

<ResponseField name={"append"} type={"boolean"} required />
