假设我的应用程序的文件结构如下:
Data/prefs.ini
executable.exe如何打开prefs.ini,从executable.exe提供到它的相对路径总是相同的(编译时知道)?或者如何获得executable.exe的绝对路径?我需要它在Linux、Mac和Windows上工作。
发布于 2015-04-19 11:11:27
有一个精确的haxe:Sys.executablePath() (文档)
要获得相对于它的路径:
import haxe.io.Path;
class Test {
static public function relToExe(path:String):String {
return Path.join([Path.directory(Sys.executablePath()), path]);
}
static function main() {
trace(relToExe("something"));
}
}https://stackoverflow.com/questions/29727407
复制相似问题