# FileSystemManager.mkdirSync(string dirPath, boolean recursive)
with Promise style call: Not supported
Mini Program plugin: Support, need to Mini Program base library version no less than 2.19.2
FileSystemManager.mkdir The synchronous version of
# parameter
# string dirPath
Directory path created (Local path)
# boolean recursive
Start from base library version 2.3.0. Please remaining backward compatible.
Whether to create this directory after recursively creating its parent directory. If the corresponding parent directory already exists, the parent directory is not created. Such as dirPath for a/b/c/d and recursive for True, will create the a Directory, and then in the a Create under directory b Directory, and so on until the a/b/c Directory d Directory.
# error
Error code | Error message | Introductions |
---|---|---|
fail No such file or directory ${dirPath} | There is no parent directory | |
fail permission denied, open ${dirPath} | Specified filePath Path does not have write permissions | |
fail file already exists ${dirPath} | Has a file or directory with the same name | |
fail sdcard not mounted | Android sdcard Mount failure |
# sample code
const fs = wx.getFileSystemManager()
fs.mkdir({
dirPath: `${wx.env.USER_DATA_PATH}/example`,
recursive: false
success(res) {
console.log(res)
},
fail(res) {
console.error(res)
}
})
// Synchronous interface
try {
fs.mkdirSync(`${wx.env.USER_DATA_PATH}/example`, false)
} catch(e) {
console.error(e)
}