---
title: seekToEndOfFile()
framework: foundation
role: symbol
role_heading: Instance Method
path: foundation/filehandle/seektoendoffile()
---

# seekToEndOfFile()

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

## Declaration

```swift
func seekToEndOfFile() -> 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 Raises fileHandleOperationException 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

### Deprecated

- [readDataToEndOfFile()](foundation/filehandle/readdatatoendoffile().md)
- [readData(ofLength:)](foundation/filehandle/readdata(oflength:).md)
- [write(_:)](foundation/filehandle/write(_:).md)
- [offsetInFile](foundation/filehandle/offsetinfile.md)
- [seek(toFileOffset:)](foundation/filehandle/seek(tofileoffset:).md)
- [closeFile()](foundation/filehandle/closefile().md)
- [synchronizeFile()](foundation/filehandle/synchronizefile().md)
- [truncateFile(atOffset:)](foundation/filehandle/truncatefile(atoffset:).md)
- [NSFileHandleNotificationMonitorModes](foundation/nsfilehandlenotificationmonitormodes.md)
