I have a path in a variable, for example:
D:\foo\bar\baz\file.txt
It could also be:
/foo/bar/baz/file.txt
I need a cross platform way to go to a directory bar
.
I found only one way, but it looks like a hack:
writeln(mystr.replaceLast("baz" ~ dirSeparator ~ "file.txt", ""));
source
share