# FileSystemManager.unlinkSync(string filePath)
with Promise style call: Not supported
Mini Program plugin: Support, need to Mini Program base library version no less than 2.19.2
FileSystemManager.unlink The synchronous version of
# parameter
# string filePath
File path to delete (Local path)
# error
Error code | Error message | Introductions |
---|---|---|
fail permission denied, open ${path} | Specified path Path not read | |
fail No such file or directory ${path} | File does not exist | |
fail operation not permitted, unlink ${filePath} | Incoming filePath It's a directory. | |
fail sdcard not mounted | Android sdcard Mount failure |
# sample code
const fs = wx.getFileSystemManager()
fs.unlink({
filePath: `${wx.env.USER_DATA_PATH}/hello.txt`,
success(res) {
console.log(res)
},
fail(res) {
console.error(res)
}
})
// Synchronous interface
try {
const res = fs.unlinkSync(`${wx.env.USER_DATA_PATH}/hello.txt`)
console.log(res)
} catch(e) {
console.error(e)
}