其实我想覆盖手机本地存储中的文件,但这给了我错误
I/flutter ( 3835): /storage/emulated/0/Android/data/com.example.temp/files/flutter_audio_recorder_
I/flutter ( 3835): Exception: A file already exists at the path :/storage/emulated/0/Android/data/com.example.temp/files/flutter_audio_recorder_.wav
所以我该如何先删除该文件?
我已经将wav文件路径存储在此变量==> var dirPath中;
Future<void> deleteFile() async {
try {
var file = File('your_file_path');
if (await file.exists()) {
// file exits, it is safe to call delete on it
await file.delete();
}
} catch (e) {
// error in getting access to the file
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句