Home > SYS_FileSystem > openReadFileDialog
SYS_FileSystem.openReadFileDialog() method
This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Open the read-file dialog
Signature
typescript
function openReadFileDialog(
filenameExtensions?: string | Array<string>,
multiFiles?: true,
): Promise<Array<File> | undefined>;1
2
3
4
2
3
4
Parameters
Parameter | Type | Description |
|---|---|---|
filenameExtensions | string | Array<string> | (Optional) File extension |
multiFiles | true | (Optional) Whether multiple files are allowed to be read |
Returns
Promise<Array<File> | undefined>
File format file array
Example
javascript
// 1. 打开选择窗口(限定 .json 文件,单选;用户选择前 Promise 一直挂起)
eda.sys_FileSystem.openReadFileDialog('.json').then((file) => {
// 用户完成选择后触发;直接关闭窗口时 file 为 undefined
if (file) {
console.log('已选择文件:', file.name);
}
});
// 2. 窗口已弹出,主流程不等待用户操作
console.log('已打开文件选择窗口');1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10