如何在Dart中找到当前目录? [英] How do I find the current directory, in Dart?

查看:733
本文介绍了如何在Dart中找到当前目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道当前目录是什么。我不想花钱运行 pwd

I want to know what the current directory is. I don't want to shell out to run pwd. Is there an easy way to do this in Dart?

推荐答案

确实存在!

import 'dart:io';

main() {
  Directory current = Directory.current;
}

注意:这仅适用于命令行,不适用于浏览器。

Note: this only works on the command-line, not in the browser.

详细了解 Directory.current的API文档

这篇关于如何在Dart中找到当前目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆