Udostępnij za pośrednictwem


IsolatedStorageFile.GetDirectoryNames Method (String)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Enumerates directories in an isolated storage scope that match a given pattern.

Namespace:  System.IO.IsolatedStorage
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
<SecuritySafeCriticalAttribute> _
Public Function GetDirectoryNames ( _
    searchPattern As String _
) As String()
[SecuritySafeCriticalAttribute]
public string[] GetDirectoryNames(
    string searchPattern
)

Parameters

  • searchPattern
    Type: System.String
    A search pattern. Both single-character ("?") and multi-character ("*") wildcards are supported.

Return Value

Type: array<System.String[]
An Array of the relative paths of directories in the isolated storage scope that match searchPattern. A zero-length array specifies that there are no directories that match.

Exceptions

Exception Condition
IsolatedStorageException

The store has been removed.

-or-

Isolated storage is disabled.

ArgumentException

searchPattern is badly formed.

ArgumentNullException

searchPattern is nulla null reference (Nothing in Visual Basic).

DirectoryNotFoundException

Cannot find a part of the searchPattern.

ObjectDisposedException

The store has been disposed.

Remarks

Wildcard characters must only be in the final element of a searchPattern. For instance, "directory1/*etc*" is a valid search string, but "*etc*/directory" is not.

The searchPattern "Project\Data*" will give all subdirectories of Project beginning with Data in the isolated storage scope. The searchPattern "*" will return all directories located in the root. For complete description of search string criteria, see the Directory class.

Examples

The following example gets an array of subdirectory names.

' Find subdirectories within the MyApp1
' directory using the multi character '*' wildcard.
Dim subDirectories() As String = _
    store.GetDirectoryNames(Path.Combine("MyApp1", "*"))
// Find subdirectories within the MyApp1
// directory using the multi character '*' wildcard.
string[] subDirectories =
    store.GetDirectoryNames(Path.Combine("MyApp1", "*"));

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.