React native React本机RNFS从下载目录中删除文件
我正试图从Android下载目录中删除一些文件。 我获得了android对外部存储的许可,因此这是我的代码:React native React本机RNFS从下载目录中删除文件,react-native,react-native-fs,rn-fetch-blob,React Native,React Native Fs,Rn Fetch Blob,我正试图从Android下载目录中删除一些文件。 我获得了android对外部存储的许可,因此这是我的代码: var RNFS = require('react-native-fs'); ... await RNFS.exists(filepath).then((exists) => { if (exists) { RNFS.unlink(filepath).then(() => { RNFS.scanFile(filepath);
var RNFS = require('react-native-fs');
...
await RNFS.exists(filepath).then((exists) => {
if (exists) {
RNFS.unlink(filepath).then(() => {
RNFS.scanFile(filepath);
})
}
});
当我在其中添加一些日志时,unlink函数可以完美地工作。它不会catch()
,但是当我再次启动同一个脚本时,取消链接仍然有效,而文件必须被删除,这怎么可能
我不明白我要怎么做才能完全删除这些文件
编辑:
我检查了react native fs
,它显示:
Android support is currently limited to only the DocumentDirectory. This maps to the app's files directory.
那么如何删除下载目录中的文件呢?您是否尝试将文件路径记录到console日志中,是否确定要传递相同的文件路径?完全相同,并且每次都会找到该文件。