# Pick Files

Let the user pick files through win32.run Files Picker dialog.

```javascript
await win32.pick_files(desc, exts, multiple);
```

### Params

#### desc

`String`

Description of the files you want to pick. It will be displayed to the user.

```javascript
let desc = 'Whatever, any files';
```

#### exts

`[String]`

Acceptable file extensions, case-insensitive. Each extension starts with a dot character.

```javascript
let exts = ['.txt', '.html', '.md'];
```

Specify an empty array \[] to accept any extension

#### multiple

`Boolean`

Default to `true`

Whether to allow the user to select multiple or single file.

### Returns

`Promise<[Object]>`

A promise that resolves with an array of objects. Each object has the following structure.

```javascript
{
    id: String, 
    //id of the file on win32.run
    //which can be used to retrieve the file later 
    //without invoking the Files Picker dialog. See Get File section

    win32_name: String, 
    //display name of the file on win32.run. 
    //could be different to name in file.name

    win32_path: String, 
    //path of the file on win32.run. 
    //it just for display purpose (like in My Computer). 
    //GET request to win32_path will not return the file content

    file: File
    //a File object, 
    //see https://developer.mozilla.org/en-US/docs/Web/API/File
}
```

This method will always return a promise of an array, regardless of the `multiple` value

### Example

```javascript
let results = await win32.pick_files('Any plain text files', ['.txt', '.html', '.md'], true);

//read text content of the first file using File.text()
let content = await results[0].file.text();
```

<figure><img src="https://2214510282-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9ZRT2QIm3d6IrehwzIeq%2Fuploads%2FjB3uHCK80md6epsHQe9T%2FScreen%20Shot%202023-02-12%20at%2011.08.11%20AM.png?alt=media&#x26;token=5eb99368-f747-4058-9891-6ad89f515a59" alt=""><figcaption></figcaption></figure>
