HomeDocs
Skip to main content

FileSystemManager.unlink

Introduction

Deletes a file.

Usage Restrictions

Supported in Basic Library version 3.0.0 or higher.

Parameters

Object object

PropertyTypeDefaultRequiredDescription
filePathstringYesThe file path (relative path) of the file to delete
successfunctionNoCallback function executed upon successful API call
failfunctionNoCallback function executed upon failed API call
completefunctionNoCallback function executed upon API call completion (executed regardless of success or failure)

object.success

Callback Function

Parameters

Object res

PropertyTypeDescription
successstringtrue - successful setting

object.fail

Callback Function

Parameters

Object res

PropertyTypeDescription
errMsgstringError message
successstringfalse - failed setting

errMsg Explanation

Error messageExplanation
parameter error: F10001Invalid parameter
fail sdcard not mounted: F10002Failed to mount Android sdcard
fail permission denied: F10005, open ${filePath}No read permission for specified filePath path
fail no such file or directory: F10007, ${path}File does not exist
fail operation not permitted, unlink ${filePath}filePath provided is a directory

Sample Code

// pages/index/index.js
Page({
unlink() {
const fs = dlt.getFileSystemManager();
fs.unlink({
filePath: `${dlt.env.USER_DATA_PATH}/hello.txt`,
success(res) {
console.log(res);
},
fail(res) {
console.error(res);
},
});
},
});
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.