本文介绍了Flutter删除目录文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要删除目录
中的文件。
final Directory extDir = await getTemporaryDirectory();
final String dirPath = '${extDir.path}/video';
await new Directory(dirPath).create(recursive: true);
final String filePath = '$dirPath/${timestamp()}.mp4';
我想删除此特定路径,以使应用程序不会繁琐。
我该怎么做?
有人有想法吗?
I want to delete this specific path so that app won't heavy.How can I do this?
Does anyone have an idea?
推荐答案
无需移动到目录。您将路径传递到 Directory
构造函数:
You don't need to move to the directory. You pass the path to the Directory
constructor:
import 'dart:io';
void main() {
final dir = Directory(dirPath);
dir.deleteSync(recursive: true);
}
这篇关于Flutter删除目录文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!