HomeDocs
Skip to main content

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

AttributeTypeDefault ValueRequiredDescription
dirPathstringYesDirectory path to be deleted (relative path)
recursivebooleanfalseNoWhether to recursively delete the directory. If true, the directory and all its subdirectories and files will be deleted.
successfunctionNoCallback function when the API call is successful
failfunctionNoCallback function when the API call fails
completefunctionNoCallback function when the API call ends (executed regardless of success or failure)

object.success

Callback Function

Parameters

Object res

AttributeTypeDescription
successstringtrue - success

object.fail

Callback Function

Parameters

Object res

AttributeTypeDescription
errMsgstringError message
successstringfalse - failure

errMsg Description

Error messageDescription
parameter error: F10001Invalid parameter
fail sdcard not mounted: F10002Android 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);
},
});
},
});
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.