我正在尝试使用 RNFS.mkdir 创建目录,但出现警告“无法创建目录”...
RNFS.mkdir
"react-native-fs": "^2.18.0", "react-native": "0.64.0",
我用来编写的函数如下:
const phoneStorageDir = RNFS.ExternalStorageDirectoryPath + '/MyApp/pictures/'; const createAppFolder = async () => { if (Platform.OS === 'android') { try { const granted = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE, title: 'Permissions for write access', message: 'Give permission to your storage to write a file', buttonPositive: 'ok', if (granted === PermissionsAndroid.RESULTS.GRANTED) { await RNFS.mkdir(phoneStorageDir); } else { console.log('permission denied'); return; } catch (err) {