我正在尝试添加我的RN应用程序的功能,允许用户在他们的手机文件系统中创建一个新的目录。
我尝试编写代码,以便该函数在路径/storage/emulated/0/AppName/NewFolder中创建一个目录,因为/storage/emulated/0与我用来存储用户数据的其他应用程序(如录制应用程序)使用的路径相同。
makeDirectory = () => {
const { currentFolder, units } = this.props;
const directoryName = 'New Folder'
const currentDirectory = units
const absolutePath = `/storage/emulated/0/MyApp/${currentDirectory}`
RNFS.mkdir(absolutePath)
.then((result) => {
console.log('result', result)
})
.catch((err) => {
console.warn('err', err)
})
}但是,这只会给我一个错误:无法创建目录。我觉得我在这里遗漏了一些东西,不应该将这样的文件保存到手机的系统中。
我的最终目标是让应用程序拥有自己的文件夹系统,该系统将被镜像到/storage/emulated/0/MyApp/home中
发布于 2019-04-18 18:17:14
我刚试过,我的文件夹创建成功了。
使用的
const absolutePath = `/storage/emulated/0/${currentDirectory}`用代替
const absolutePath = `/storage/emulated/0/MyApp/${currentDirectory}`https://stackoverflow.com/questions/55408709
复制相似问题