我写了下面的代码,以满足我的一些要求:
src = "E:\\Download"
dest = "E:\\Scripts\\original" #"E:\WIPData\Ruby\Scripts\"
FileUtils.copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
FileUtils.remove_dir(src , force = false)
但是 10 次中有 4 次出现以下错误。无法理解为什么我会收到这样的错误:
错误
C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:1406:in `unlink': Permission denied -
E:\\Download/BASIC USES OF THE ENGLISH TENSES.pdf.pa
rt (Errno::EACCES)
from C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:1406:in `block in remove_fil
e'
from C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:1414:in `platform_support'
from C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:1405:in `remove_file'
from C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:1394:in `remove'
from C:/Ruby193/lib/ruby/1.9.1/fileutils.rb:770:in `block in remove_entr
y'