# FileSystemManager.mkdir(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
Create a directory
# parameter
# Object object
attribute | type | Default values | Required | Introductions | Minimum version |
---|---|---|---|---|---|
dirPath | string | yes | Directory path created (Local path) | ||
recursive | boolean | false | no | 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. | 2.3.0 |
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 ${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)
}