Foundation.NSFileManager.GetUrls Method
Returns a list of commonly used directories matching the type of directory and the domain to search for.

Syntax

[Foundation.Export("URLsForDirectory:inDomains:")]
[ObjCRuntime.Availability(Introduced=ObjCRuntime.Platform.iOS_4_0)]
public virtual NSUrl[] GetUrls (NSSearchPathDirectory directory, NSSearchPathDomain domains)

Parameters

directory
The type of directory that you are looking for (for example desktop directory, documents directory, trash directory and so on).
domains
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.

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.

C# Example

var docDir = NSFileManager.DefaultManager.GetUrls (
     NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User) [0];

Some values for directory will return multiple results.   For example the value NSSearchPathDirectory.AllApplicationsDirectory would return all the valid locations for applications for a specific key.

Passing more than one value to domains has a similar effect.

c# Example

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/

Requirements

Namespace: Foundation
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0