use Dir.tmpdir with File.join to create a platform-independent way of creating a temporary file: : tmpdir « File Directory « Ruby






use Dir.tmpdir with File.join to create a platform-independent way of creating a temporary file:


require 'tmpdir'
tempfilename = File.join(Dir.tmpdir, "myapp.dat")
tempfile = File.new(tempfilename, "w")
tempfile.puts "This is only temporary"
tempfile.close
File.delete(tempfilename)

 








Related examples in the same category

1.Dir.tmpdir provides the path to the temporary directory on the current system