---
title: "init(forUpdatingAtPath:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/filehandle/init(forupdatingatpath:)"
---

# init(forUpdatingAtPath:)

Returns a file handle initialized for reading and writing to the file, device, or named socket at the specified path.

## Declaration

```swift
convenience init?(forUpdatingAtPath path: String)
```

## Parameters

- `path`: The path to the file, device, or named socket to access.

## Return Value

Return Value The initialized file handle object or nil if no file exists at path.

## Discussion

Discussion The file pointer is set to the beginning of the file. The returned object responds to both   read... messages and write(_:). When using this method to create a file handle object, the file handle owns its associated file descriptor and is responsible for closing it.

## See Also

### Related Documentation

- [availableData](foundation/filehandle/availabledata.md)
- [readData(ofLength:)](foundation/filehandle/readdata(oflength:).md)
- [readDataToEndOfFile()](foundation/filehandle/readdatatoendoffile().md)

### Creating a file handle

- [init(fileDescriptor:)](foundation/filehandle/init(filedescriptor:).md)
- [init(fileDescriptor:closeOnDealloc:)](foundation/filehandle/init(filedescriptor:closeondealloc:).md)
- [init(forReadingAtPath:)](foundation/filehandle/init(forreadingatpath:).md)
- [init(forReadingFromURL:)](foundation/filehandle/init(forreadingfromurl:).md)
- [init(forWritingAtPath:)](foundation/filehandle/init(forwritingatpath:).md)
- [init(forWritingToURL:)](foundation/filehandle/init(forwritingtourl:).md)
- [init(forUpdatingURL:)](foundation/filehandle/init(forupdatingurl:).md)
- [init(coder:)](foundation/filehandle/init(coder:).md)
