# FileSystemManager.appendFileSync(string filePath, string|ArrayBuffer data, string encoding)

Start from base library version 2.1.0. Please remaining backward compatible.

with Promise style call: Not supported

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

FileSystemManager.appendFile The synchronous version of

# parameter

# string filePath

File path to append content (Local path)

# string|ArrayBuffer data

Text or binary data to append

# string encoding

Specifies the character encoding for writing to the file

encoding Legal value

value Introductions Minimum version
ascii
base64
binary
hex
ucs2 Read in small endorder
ucs-2 Read in small endorder
Utf16le Read in small endorder
utf-16le Read in small endorder
utf-8
utf8
latin1

# error

Error code Error message Introductions
fail No such file or directory, open ${filePath} Specified filePath File does not exist
fail illegal operation on a directory, open "${filePath}" Specified filePath It's an existing directory.
fail permission denied, open ${dirPath} Specified filePath Path does not have write permissions
fail sdcard not mounted Android sdcard Mount failure

# sample code

const fs = wx.getFileSystemManager()

fs.appendFile({
  filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, 
  data: 'some text',
  encoding: 'utf8',
  success(res) {
    console.log(res)
  },
  fail(res) {
    console.error(res)
  }
})

// Synchronous interface
try {
  fs.appendFileSync(`${wx.env.USER_DATA_PATH}/hello.txt`,  'some text', 'utf8')
} catch(e) {
  console.error(e)
}