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

# icon(forFile:)

Returns an image containing the icon for the specified file.

```
func icon(forFile fullPath: String) -> NSImage
```

## Parameters

`fullPath`

The full path to the file.

## Return Value

The icon associated with the file.

## Discussion

The returned image has an initial size of 32 pixels by 32 pixels.

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

## See Also

[`icon(forFileType:)`](/documentation/AppKit/NSWorkspace/icon(forFileType:))

Returns an image containing the icon for files of the specified type.

[`getInfoForFile(_:application:type:)`](/documentation/AppKit/NSWorkspace/getInfoForFile(_:application:type:))

Retrieves information about the specified file.



---

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)