Use the basename() , dirname() , basenameWithoutExtension() , and extension() methods defined in the path Pub package when working with a file path.
import 'package:path/path.dart' as path; import 'dart:io'; main() async { // Create dir/ and dir/file.txt in the system temp directory. var file = await new File('${Directory.systemTemp.path}/dir/myFile.txt') .create(recursive: true); print(path.basename(file.path)); // Prints 'file.txt'. print(path.dirname(file.path)); // Prints path ending with 'dir'. print(path.basenameWithoutExtension(file.path)); // Prints 'myFile'. print(path.extension(file.path)); // Prints '.txt'. }
查看更多关于使用系统API获取文件路径相关的信息的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did129462