创建文件夹
folderExists(String filepath) async {
var file = Directory(filepath);
try {
bool exists = await file.exists();
if (!exists) {
await file.create();
}
} catch (e) {
print(e);
}
创建文件
Future<File> getFile(String path,String fileName) async {
final filePath = path+"/"+fileName;
return new File(filePath);
}
删除文件
Directory directory = new Directory(path);
if (directory.existsSync()) {
List<FileSystemEntity> files = directory.listSync();
if (files.length > 0) {
files.forEach((file) {
file.deleteSync();
});
}
directory.deleteSync();
}