harmony 鸿蒙@ohos.document (File Operation)
@ohos.document (File Operation)
NOTE
- The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
- The APIs provided by this module have been deprecated since API version 9 and are not recommended for use. An exception will be thrown if any of the APIs is called.
Modules to Import
import document from '@ohos.document';
document.choose(deprecated)
choose(types?: string[]): Promise<string>
Chooses files of the specified types using the file manager. This API uses a promise to return the result.
System capability: SystemCapability.FileManagement.UserFileService
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
types | string[] | No | Types of the files to choose. |
Return value
Type | Description |
---|---|
Promise<string> | Promise used to return the result. An error code is returned. |
Example
let types: Array<string> = [];
document.choose(types);
document.choose(deprecated)
choose(callback:AsyncCallback<string>): void
Chooses a file using the file manager. This API uses an asynchronous callback to return the result.
System capability: SystemCapability.FileManagement.UserFileService
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned. |
Example
let uri: string = "";
document.choose((err: TypeError, uri: string) => {
// Do something with the URI.
});
document.choose(deprecated)
choose(types:string[], callback:AsyncCallback<string>): void
Chooses files using the file manager. This API uses an asynchronous callback to return the result.
System capability: SystemCapability.FileManagement.UserFileService
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
types | string[] | No | Types of the files to choose. |
callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned. |
Example
let types: Array<string> = [];
let uri: string = "";
document.choose(types, (err: TypeError, uri: string) => {
// Do something with the URI.
});
document.show(deprecated)
show(uri:string, type:string):Promise<void>
Opens a file. This API uses a promise to return the result.
System capability: SystemCapability.FileManagement.UserFileService
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
uri | string | Yes | URI of the file to open. |
type | string | Yes | Type of the file to open. |
Return value
Type | Description |
---|---|
Promise<void> | Promise used to return the result. An error code is returned. |
Example
let type: string = "";
let uri: string = "";
document.show(uri, type);
document.show(deprecated)
show(uri:string, type:string, callback:AsyncCallback<void>): void
Opens a file. This API uses an asynchronous callback to return the result.
System capability: SystemCapability.FileManagement.UserFileService
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
uri | string | Yes | URI of the file to open. |
type | string | Yes | Type of the file to open. |
callback | AsyncCallback<void> | Yes | Callback used to return the result. An error code is returned. |
Example
let type: string = "";
let uri: string = "";
document.show(uri, type, (err: TypeError) => {
//do something
});
你可能感兴趣的鸿蒙文章
harmony 鸿蒙System Common Events (To Be Deprecated Soon)
harmony 鸿蒙System Common Events
harmony 鸿蒙API Reference Document Description
harmony 鸿蒙Enterprise Device Management Overview (for System Applications Only)
harmony 鸿蒙BundleStatusCallback
harmony 鸿蒙@ohos.bundle.innerBundleManager (innerBundleManager)
harmony 鸿蒙@ohos.distributedBundle (Distributed Bundle Management)
harmony 鸿蒙@ohos.bundle (Bundle)
harmony 鸿蒙@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦