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

# selectFile(_:inFileViewerRootedAtPath:)

Selects the file at the specified path.

```
func selectFile(_ fullPath: String?, inFileViewerRootedAtPath rootFullPath: String) -> Bool
```

## Parameters

`fullPath`

The full path of the file to select.

`rootFullPath`

The path to use for the file viewer. If you specify a nonempty path string, this method opens a new file viewer. If you specify an empty string (`@""`), this method selects the file in the main viewer.

## Return Value

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

## Discussion

In macOS 10.5 and later, this method does not follow symlinks when selecting the file. If the `fullPath` parameter contains any symlinks, this method selects the symlink instead of the file it targets. If you want to select the target file, use the <doc://com.apple.documentation/documentation/Foundation/NSString/resolvingSymlinksInPath> method to resolve any symlinks before calling this method.

You can safely call this method from any thread of your app.

---

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)