# FileSystemManager.accessSync(string path)
with Promise style call: Not supported
Mini Program plugin: Support, need to Mini Program base library version no less than 2.19.2
FileSystemManager.access The synchronous version of
# parameter
# string path
Files to determine if they exist/Directory path (Local path)
# error
Error code | Error message | Introductions |
---|---|---|
fail No such file or directory ${path} | file/Directory does not exist | |
fail sdcard not mounted | Android sdcard Mount failure |
# sample code
const fs = wx.getFileSystemManager()
// Judgment file/Directory exists
fs.access({
path: `${wx.env.USER_DATA_PATH}/hello.txt`,
success(res) {
// File existence
console.log(res)
},
fail(res) {
// File does not exist or other error
console.error(res)
}
})
// Synchronous interface
try {
fs.accessSync(`${wx.env.USER_DATA_PATH}/hello.txt`)
} catch(e) {
console.error(e)
}
The translations are provided by WeChat Translation and are for reference only. In case of any inconsistency and discrepancy between the Chinese version and the English version, the Chinese version shall prevail.Incorrect translation. Tap to report.