Table of Contents

Class FileChooser

Namespace
PuppeteerSharp
Assembly
PuppeteerSharp.dll

FileChooser objects are returned via the WaitForFileChooserAsync(WaitForOptions) method. File choosers let you react to the page requesting for a file.

public class FileChooser
Inheritance
FileChooser

Examples

var waitTask = page.WaitForFileChooserAsync();
await Task.WhenAll(
    waitTask,
    page.ClickAsync("#upload-file-button")); // some button that triggers file selection

await waitTask.Result.AcceptAsync('/tmp/myfile.pdf');

Remarks

In browsers, only one file chooser can be opened at a time. All file choosers must be accepted or canceled. Not doing so will prevent subsequent file choosers from appearing.

Properties

IsMultiple

Whether file chooser allow for multiple file selection.

public bool IsMultiple { get; }

Property Value

bool

Methods

AcceptAsync(params string[])

Accept the file chooser request with given paths. If some of the filePaths are relative paths, then they are resolved relative to the current working directory.

public Task AcceptAsync(params string[] filePaths)

Parameters

filePaths string[]

File paths to send to the file chooser.

Returns

Task

A task that resolves after the accept message is processed by the browser.

CancelAsync()

Closes the file chooser without selecting any files.

public Task CancelAsync()

Returns

Task

A task that resolves after the cancel event is sent to the browser.