Reputation: 353
For example, I have this structure:
/home/user <- my current dir
/home/user/app/bin/main.dart <- entry point of my application
How I can get a path to the folder from which the script has been started? For example, I start main.dart
from /home/user
folder by:
dart app/bin/main.dart
Inside main.dart
I need get the path /home/user
. Is this possible?
Upvotes: 3
Views: 1226
Reputation: 657058
I assume this is what you are looking for.
import 'dart:io';
void main() {
print(Platform.script);
print(Platform.script.toFilePath(windows: true));
// or
print(Directory.current.absolute.path);
}
see also How do I get the script path in Dart?
Upvotes: 4