---
title: fileDescriptor
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/filehandle/filedescriptor
---

# fileDescriptor

The POSIX file descriptor associated with the receiver.

## Declaration

```swift
var fileDescriptor: Int32 { get }
```

## Discussion

Discussion You can use this method to retrieve the file descriptor while it is open. If the file handle object owns the file descriptor, you must not close it yourself. However, you can use the closeFile() method to close the file descriptor programmatically. If you do call the closeFile() method, subsequent calls to this method raise an exception.

## See Also

### Related Documentation

- [init(fileDescriptor:)](foundation/filehandle/init(filedescriptor:).md)
