获取绝对路径

1981次阅读  |  发布于5年以前

获取绝对路径

Use Platform.script to get the absolute URI of the script being run in the current isolate.

import 'dart:io' show Platform;

main() {
  // Get the URI of the script being run.
  var uri = Platform.script;
  print(uri); // Prints something like '/Users/shailentuli/workspace/...'.

  // Convert the URI to a path.
  var path = uri.toFilePath();
  print(
      path); // Prints something like 'file:///Users/shailentuli/workspace/...'.
}

Copyright© 2013-2019

京ICP备2023019179号-2