---
title: "seek(toOffset:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/filehandle/seek(tooffset:)"
---

# seek(toOffset:)

Moves the file pointer to the specified offset within the file.

## Declaration

```swift
func seek(toOffset offset: UInt64) throws
```

## Parameters

- `offset`: The offset to seek to.

## Discussion

Discussion note: Throws an error if called on a file handle representing a pipe or socket, if the file descriptor is closed, or if any other error occurs while seeking.

## See Also

### Seeking within a file

- [offset()](foundation/filehandle/offset().md)
- [seekToEnd()](foundation/filehandle/seektoend().md)
