tags:

views:

45

answers:

3

I'm wondering how I can read the current working directory of a file being "parsed" by IronRuby. It appears the "execution directory" is the same as the ir.exe file.

I need this to create a relative path to content in a XNA solution without hardcoding the path.

+1  A: 

I think I found the solution in Dir.pwd

Silly me forgot that pwd is not an acronym for password but for print working directory...

Embarassing :)

Johan Lindfors
+4  A: 

From Class:Dir:

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"
ire_and_curses
+1  A: 

You can also use the CLR way of doing things if you feel like it:

include System
Environment.current_directory => clr_string
Orion Edwards