<!--
{
  "availability" : [
    "iOS: 13.4.0 -",
    "iPadOS: 13.4.0 -",
    "macCatalyst: 13.4.0 -",
    "macOS: 10.15.4 -",
    "tvOS: 13.4.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.2.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/FileHandle/seekToEnd()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:So12NSFileHandleC10FoundationE9seekToEnds6UInt64VyKF"
  },
  "title" : "seekToEnd()"
}
-->

# seekToEnd()

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

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

## 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

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

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)