Share via


IFileDialogService.SelectDirectoryAsync Method

Definition

Selects a directory using the common file dialog.

public System.Threading.Tasks.ValueTask<string> SelectDirectoryAsync(string title, string initialDirectory, System.Threading.CancellationToken cancellationToken);
abstract member SelectDirectoryAsync : string * string * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<string>
Public Function SelectDirectoryAsync (title As String, initialDirectory As String, cancellationToken As CancellationToken) As ValueTask(Of String)

Parameters

title
String

The dialog title. Leave this empty to use the default behavior.

initialDirectory
String

The initial directory. This should be an absolute path. Leave this empty to use the default behavior.

cancellationToken
CancellationToken

The cancellation token. Will throw if cancellation is requested before opening the dialog. The user must close the dialog for any requested cancellation to take affect when the dialog is open.

Returns

A string representing the selected directory. If the user closes or cancels the dialog, then this returns an empty string.

Exceptions

If the dialog fails to open or fails to retrieve the selected directory, then this will throw.

Applies to