views:

84

answers:

1

I have

f = File.new(contacts_file_path, "wb")
f.write params[:uploaded_file].read
f.close

I want

begin
  f = File.new(contacts_file_path, "wb")
  f.write params[:uploaded_file].read
rescue
  #error
ensure
  if f.open? then f.close end
end

But f.open? is not a function and I can't find any api documentation. Any ideas?

A: 
f.close unless f.closed?
Greg Dan