F# for scripting: location of script file

给你一囗甜甜゛ 提交于 2019-11-29 04:56:24

问题


In an F# script file (.fsx), how can I determine the location of the .fsx file currently executing? I'd like to resolve paths relative to it.

I tried Assembly.GetExecutingAssembly().CodeBase but that doesn't work in a "dynamic assembly", apparently.


回答1:


extract from F# spec:

__SOURCE_DIRECTORY__ - Replaced by a literal verbatim string that specifies the name of the directory that contains the current file, for example, C:\source. The name of the current file is determined by the most recent line directive in the file. If no line directive has been given, the name is determined by that given to the command-line compiler in combination with System.IO.Path.GetFullPath.

__SOURCE_FILE__ - Replaced by a literal verbatim string that contains the name of the current file, for example, file.fs



来源:https://stackoverflow.com/questions/4860991/f-for-scripting-location-of-script-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!