---
title: seekToEnd()
framework: foundation
role: symbol
role_heading: Instance Method
path: foundation/filehandle/seektoend()
---

# seekToEnd()

Places the file pointer at the end of the file referenced by the file handle and returns the new file offset.

## Declaration

```swift
@discardableResult func seekToEnd() throws -> UInt64
```

## Return Value

Return Value The file offset with the file pointer at the end of the file. This is therefore equal to the size of the file.

## Discussion

Discussion Throws an error if called a file handle representing a pipe or socket, or if the file descriptor is closed.

## See Also

### Seeking within a file

- [offset()](foundation/filehandle/offset().md)
- [seek(toOffset:)](foundation/filehandle/seek(tooffset:).md)
