jack
jack

Reputation: 1435

Error while moving a file (Errno::ENOENT)

I face the error when I try to move one file from another. I'm sure that path is correct. The platform is windows. Permission is correct.

My code is below:

  unless File.exists?(f2)
    FileUtils.move(f1,f2)
  end

Note I don't face problem with every file.

Upvotes: 1

Views: 342

Answers (1)

roberto tomás
roberto tomás

Reputation: 4687

FileUtils.move(f1,f2) rescue do
    not File.exists?(f1) and raise "source file does not exist"
    File.exists?(f2) and raise "destination file already exists"
end

question should be closable now

Upvotes: 1

Related Questions