2

我想知道如何读取 IronRuby 正在“解析”的文件的当前工作目录。看起来“执行目录”与 ir.exe 文件相同。

我需要它来创建 XNA 解决方案中内容的相对路径,而无需对路径进行硬编码。

4

3 回答 3

4

类:目录

Dir.getwd => string
Dir.pwd => string

Returns the path to the current working directory of this process as a string.

Dir.chdir("/tmp")   #=> 0
Dir.getwd           #=> "/tmp"
于 2009-08-08T11:07:31.770 回答
1

我想我在 Dir.pwd 中找到了解决方案

愚蠢的我忘记了 pwd 不是密码的首字母缩写词,而是打印工作目录的首字母缩写词......

尴尬:)

于 2009-08-08T11:06:23.800 回答
1

如果您愿意,也可以使用 CLR 的处理方式:

include System
Environment.current_directory => clr_string
于 2009-08-16T20:59:10.277 回答