FileSystemManager.rmdir
Introduction
This function is used to delete a directory.
Usage Restrictions
This feature is supported in Basic Library version 3.0.0 or higher.
Parameters
Object object
Attribute | Type | Default Value | Required | Description |
---|---|---|---|---|
dirPath | string | Yes | Directory path to be deleted (relative path) | |
recursive | boolean | false | No | Whether to recursively delete the directory. If true, the directory and all its subdirectories and files will be deleted. |
success | function | No | Callback function when the API call is successful | |
fail | function | No | Callback function when the API call fails | |
complete | function | No | Callback function when the API call ends (executed regardless of success or failure) |
object.success
Callback Function
Parameters
Object res
Attribute | Type | Description |
---|---|---|
success | string | true - success |
object.fail
Callback Function
Parameters
Object res
Attribute | Type | Description |
---|---|---|
errMsg | string | Error message |
success | string | false - failure |
errMsg Description
Error message | Description |
---|---|
parameter error: F10001 | Invalid parameter |
fail sdcard not mounted: F10002 | Android sdcard mounting failed |
fail permission denied: F10005, open ${dirPath} | The specified dirPath does not have read permission |
fail no such file or directory: F10007 ${dirPath}. | Parent directory does not exist (This error only works when recursive = false) |
fail not a directory ${dirPath} | dirPath is not a directory |
Sample Code
// pages/index/index.js
Page({
rmdir() {
const fs = dlt.getFileSystemManager();
fs.rmdir({
dirPath: `${dlt.env.USER_DATA_PATH}/example`,
success(res) {
console.log(res);
},
fail(res) {
console.error(res);
},
});
},
});