问题
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?
回答1:
Indeed there is!
import 'dart:io';
main() {
Directory current = Directory.current;
}
Note: this only works on the command-line, not in the browser.
Read more about the API docs for Directory.current.
来源:https://stackoverflow.com/questions/19436793/how-do-i-find-the-current-directory-in-dart