# FileSystemManager.unlinkSync(string filePath)
以 Promise 风格 调用:不支持
相关文档: 文件系统
# 功能描述
FileSystemManager.unlink 的同步版本
# 参数
# string filePath
要删除的文件路径 (本地路径)
# 错误
错误码 | 错误信息 | 说明 |
---|---|---|
fail permission denied, open ${path} | 指定的 path 路径没有读权限 | |
fail no such file or directory ${path} | 文件不存在 | |
fail operation not permitted, unlink ${filePath} | 传入的 filePath 是一个目录 | |
fail sdcard not mounted | Android sdcard 挂载失败 |
# 示例代码
const fs = wx.getFileSystemManager()
fs.unlink({
filePath: `${wx.env.USER_DATA_PATH}/hello.txt`,
success(res) {
console.log(res)
},
fail(res) {
console.error(res)
}
})
// 同步接口
try {
const res = fs.unlinkSync(`${wx.env.USER_DATA_PATH}/hello.txt`)
console.log(res)
} catch(e) {
console.error(e)
}