writeFileSync

发布于 8 年前作者 yang198048 次浏览最后编辑 8 年前来自 ask

wx.getSavedFileList({

success:function(res){

if(res.fileList.length==0){

let fs = wx.getFileSystemManager();

fs.writeFileSync(`${wx.env.USER_DATA_PATH}/hello.txt`, ‘hello, world’, ‘utf8’)

}

}

})

为什么没有创建文件

2 回复
yang62
yang621 楼6 年前

https://developers.weixin.qq.com/miniprogram/dev/framework/ability/file-system.html 文件是有几种类型的,getSavedFileList 操作的是本地缓存文件,writeFileSync 操作的是本地用户文件,两者间不存在关系。

guiying60
guiying602 楼6 年前

请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。