<!--
{
  "availability" : [
    "macOS: 10.0.0 - 11.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWorkspace/openFile(_:withApplication:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSWorkspace(im)openFile:withApplication:"
  },
  "title" : "openFile(_:withApplication:)"
}
-->

# openFile(_:withApplication:)

Opens a file using the specified app.

```
func openFile(_ fullPath: String, withApplication appName: String?) -> Bool
```

## Parameters

`fullPath`

The full path to the file.

`appName`

The name of the app to use when opening the file.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the file was successfully opened; otherwise, <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

The `appName` parameter need not be specified with a full path and, in the case of an app wrapper, may be specified with or without the `.app` extension. The sending app is deactivated before the request is sent.

It is safe to call this method from any thread in your app in macOS 10.6 and later.

---

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)