NSFileManager.GetUrls(NSSearchPathDirectory, NSSearchPathDomain) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns a list of commonly used directories matching the type of directory and the domain to search for.
[Foundation.Export("URLsForDirectory:inDomains:")]
public virtual Foundation.NSUrl[] GetUrls (Foundation.NSSearchPathDirectory directory, Foundation.NSSearchPathDomain domains);
abstract member GetUrls : Foundation.NSSearchPathDirectory * Foundation.NSSearchPathDomain -> Foundation.NSUrl[]
override this.GetUrls : Foundation.NSSearchPathDirectory * Foundation.NSSearchPathDomain -> Foundation.NSUrl[]
Parameters
- directory
- NSSearchPathDirectory
The type of directory that you are looking for (for example desktop directory, documents directory, trash directory and so on).
- domains
- NSSearchPathDomain
The domain is used to specify a mask for the base location (for example relative to the user home, a system directory, or a network directory).
Returns
An array of URLs with the locations for the requested location for all the matching domains requested. Starting with the user domain.
- Attributes
Remarks
This method is used to find the location of various system directories. The directory
parameter specifies the kind of directory that you want to look for and the domains
parameter is a bitmask that describes which matches should be returned (local, system, networked).
The array returned would contain one or more matches for the specified directory and the domains where it would be located.
This can be used to get the Documents directory in an iOS application.
var docDir = NSFileManager.DefaultManager.GetUrls (
NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User) [0];
Some values for directory
will return multiple results. For example the value AllApplicationsDirectory would return all the valid locations for applications for a specific key.
Passing more than one value to domains
has a similar effect.
var mgr = NSFileManager.DefaultManager;
var urls = mgr.GetUrls (NSSearchPathDirectory.AllApplicationsDirectory, NSSearchPathDomain.System);
foreach (var url in urls)
Console.WriteLine (url);
// Produces:
// file:///Applications/
// file:///Applications/Utilities/
// file:///Developer/Applications/
// file:///Applications/Demos/
urls = GetUrls (NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomain.System | NSSearchPathDomain.Local))
foreach (var url in urls)
Console.WriteLine (url);
// Produces
// file:///Library/
// file:///System/Library/