Ruby - File Directory Change

Introduction

To change directory within a Ruby program, use Dir.chdir:

Dir.chdir("/usr/bin") 

This example changes the current directory to /usr/bin.

You can find out what the current directory is with Dir.pwd.

For example, here's the result on my installation:

Demo

puts Dir.pwd 

Dir.chdir("C:/") 
puts Dir.pwd# from w  ww .  j av  a2 s  . co m

Result

Related Topic