1

I have a directory structure like:

-project -dart -src -test -mytest.dart -test_data -testdata.csv

And in the mytest.dart I want to access testdata.csv, what is the best way to get the absolute and platform independent path to testdata.csv from mytest.dart?

This works, but maybe there is a better way?:

Directory projectRoot = new Directory.fromUri(Platform.script).parent.parent.parent;
String testDataPath = path.absolute(projectRoot.path, 'test_data', 'testdata.csv');
mdakin
  • 1,310
  • 11
  • 17
  • Why do you need an absolute path? – Robert Jun 24 '15 at 15:29
  • Are you using the new test or the old unittest package? Your directory layout doesn't conform to the pub package layout convention, this is likely to cause troubles. https://www.dartlang.org/tools/pub/package-layout.html – Günter Zöchbauer Jun 24 '15 at 16:09
  • Günter Zöchbauer, I know but the directory structure is not under my control. There are other languages in the root directory (implementing same library) and they all use the same test files. – mdakin Jun 24 '15 at 20:40

0 Answers0