# FileSystemManager.access(Object object)

with Promise style call: Not supported

Mini Program plugin: Support, need to Mini Program base library version no less than 2.19.2

Judgment file/Directory exists

# parameter

# Object object

attribute type Default values Required Introductions
path string yes Files to determine if they exist/Directory path (Local path)
success function no Interface calls the successful callback function
fail function no Interface calls failed callback functions
complete function no Callback function at the end of an interface call (both successful and unsuccessful calls are executed)

# object.fail callback

# parameter
# Object res
attribute type Introductions
errMsg string Error message

res.errMsg Legal value

value Introductions Minimum version
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(and) {
  console.error(and)
}