---
title: "path(forResource:ofType:inDirectory:forLocalization:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/bundle/path(forresource:oftype:indirectory:forlocalization:)"
---

# path(forResource:ofType:inDirectory:forLocalization:)

Returns the full pathname for the resource identified by the specified name and file extension, located in the specified bundle subdirectory, and limited to global resources and those associated with the specified localization.

## Declaration

```swift
func path(forResource name: String?, ofType ext: String?, inDirectory subpath: String?, forLocalization localizationName: String?) -> String?
```

## Parameters

- `name`: The name of the resource file. If you specify nil, the method returns the first resource file it finds that matches the remaining criteria.
- `ext`: The filename extension of the files to locate. If you specify an empty string or nil, the extension is assumed not to exist and the file is the first file encountered that exactly matches name.
- `subpath`: The name of the bundle subdirectory to search.
- `localizationName`: The language ID for of the localization. This parameter should correspond to the name of one of the bundle’s language-specific resource directories without the .lproj extension.

## Return Value

Return Value The full pathname for the resource file or nil if the file could not be located.

## Discussion

Discussion This method is equivalent to path(forResource:ofType:inDirectory:), except that only nonlocalized resources and those in the language-specific .lproj directory specified by localizationName are searched. There should typically be little reason to use this method—see Getting the Current Language and Locale. See also preferredLocalizations(from:forPreferences:) for how to determine what localizations are available.

## See Also

### Finding resource files

- [url(forResource:withExtension:subdirectory:)](foundation/bundle/url(forresource:withextension:subdirectory:).md)
- [url(forResource:withExtension:)](foundation/bundle/url(forresource:withextension:).md)
- [urls(forResourcesWithExtension:subdirectory:)](foundation/bundle/urls(forresourceswithextension:subdirectory:).md)
- [url(forResource:withExtension:subdirectory:localization:)](foundation/bundle/url(forresource:withextension:subdirectory:localization:).md)
- [urls(forResourcesWithExtension:subdirectory:localization:)](foundation/bundle/urls(forresourceswithextension:subdirectory:localization:).md)
- [url(forResource:withExtension:subdirectory:in:)](foundation/bundle/url(forresource:withextension:subdirectory:in:).md)
- [urls(forResourcesWithExtension:subdirectory:in:)](foundation/bundle/urls(forresourceswithextension:subdirectory:in:).md)
- [path(forResource:ofType:)](foundation/bundle/path(forresource:oftype:).md)
- [path(forResource:ofType:inDirectory:)](foundation/bundle/path(forresource:oftype:indirectory:)-swift.method.md)
- [paths(forResourcesOfType:inDirectory:)](foundation/bundle/paths(forresourcesoftype:indirectory:)-swift.method.md)
- [paths(forResourcesOfType:inDirectory:forLocalization:)](foundation/bundle/paths(forresourcesoftype:indirectory:forlocalization:).md)
- [path(forResource:ofType:inDirectory:)](foundation/bundle/path(forresource:oftype:indirectory:)-swift.type.method.md)
- [paths(forResourcesOfType:inDirectory:)](foundation/bundle/paths(forresourcesoftype:indirectory:)-swift.type.method.md)
