我正在尝试向我的 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 中
const AppFolder = 'DirNameyouwant';
const DirectoryPath= RNFS.ExternalStorageDirectoryPath +'/'+ AppFolder;
RNFS.mkdir(DirectoryPath);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)