在Dart中,希望检查一个目录是否存在,但不知道这个目录的子字符串是什么:
例如:
dir = preview/1552146038702.jpg.1--001--001.html.test.jpg
我尝试了以下代码:
io.Directory(await dir).exists().then((exist){
但是在我不知道的目录下,有一个名为 1--001--001.html 的文件。
有什么想法吗?
在Dart中,希望检查一个目录是否存在,但不知道这个目录的子字符串是什么:
例如:
dir = preview/1552146038702.jpg.1--001--001.html.test.jpg
我尝试了以下代码:
io.Directory(await dir).exists().then((exist){
但是在我不知道的目录下,有一个名为 1--001--001.html 的文件。
有什么想法吗?
Directory.exists()
提供了这个信息。
使用以下代码检查目录是否存在:
bool exists = await Directory(path).exists();
说明:以上链接为相关文档。这对我有效,希望我的答案能帮到你
final path = '/storage/emulated/0/Download';
final checkPathExistence = await Directory(path).exists();
import 'dart:io';