File.delete()-Permission denied error in windows

All,

I am running a Ruby on Rails application in windows. I am getting
"Permission denied error when delete a file". Also I am getting when
move a file from one directory to another directory.

Please find the below code,

source_dir = "public/BuildingImages/Building1"
destination_dir = "public/BuildingImages/Building2"

Dir.mkdir(destination_dir) unless File.directory?(destination_dir)

FileUtils.mv(source_dir, destination_dir) # To move the file

# File.delete(source_dir) # To delete a file

Please let me know comments if you have any ideas?

Thanks,
Periyasamy

···

--
Posted via http://www.ruby-forum.com/.

Mmmm, not prety sure, but when you are moving a file or dir with
FileUtils, you are deleting it too from the previous location.

···

--
Posted via http://www.ruby-forum.com/.

What OS do you have?

···

--
Posted via http://www.ruby-forum.com/.

I don't have many time so research(working...). My suggestion is: look
at File.chmod() or File#chmod() methods. Perhaps some of your files
inside the source directory is being used by the app, or Windows. Here
you have another suggestion..

That's all what I have for now...

···

--
Posted via http://www.ruby-forum.com/.

Damián M. González wrote in post #1064721:

Mmmm, not prety sure, but when you are moving a file or dir with
FileUtils, you are deleting it too from the previous location, so the
work is done simply calling the mv() FileUtils method, you don't have to
'delete' it...

Damian,

Thanks for your reply. You are right!. First I tired to move the file
from one directory to another directory. Then, I got the permission
denied error and the file can't be moved. So, I tried in another
solution instead of mv() (moving file), I just tried to copy the file to
the destination directory. Here, the file is copied to the destination
directory. But I am unable to delete the source file when I use
"File.delete(file)". Because I am getting the same "Permission denied
error".

Please let me know your comments.

Thanks,

Periyasamy

···

--
Posted via http://www.ruby-forum.com/\.

Damián M. González wrote in post #1064725:

What OS do you have?

I am running in windows. I also gave all the permission (Full Control)
for "administrator" user.

But I didn't get this permission error in Linux machine.

Thanks,

Periyasamy

···

--
Posted via http://www.ruby-forum.com/\.

Damián M. González wrote in post #1064727:

I don't have many time so research(working...). My suggestion is: look
at File.chmod() or File#chmod() methods. Perhaps some of your files
inside the source directory is being used by the app, or Windows. Here
you have another suggestion..

Ruby FileUtils.chmod in Windows - Stack Overflow

That's all what I have for now...

Thanks for your comments. I'll try to give the permission.

···

--
Posted via http://www.ruby-forum.com/\.