title: Cannot use File.delete to remove file
body: <p>System:</p>
  
  <pre>
  Windows Server 2008
  Ruby 192
  </pre>
  
  <p>in 'delete': Permission denied Errno:EACCES</p>
  
  <p>the line: File.delete('filename.ext') </p>
  
  <p>If you know any other method to delete the file bypassing this error I'm glad to distribute you some points :) I mean any help would be appreciated ;-p</p>
  
  <p>I was suspecting that file wasn't closed but it is closed.</p>
  
  <p><em>Source code:</em></p>
  
  <pre><code>Dir.foreach(FileUtils.pwd()) do |f|
    a[i] = f
    if a[i].end_with?('log')
      file = File.open(a[i])
      if file.ctime &lt; TIME_TO_REMOVE_LOGS || file.mtime &lt; TIME_TO_REMOVE_LOGS || File.size(a[i]) &gt; MAX_FILE_SIZE
        puts a[i]
        puts file.ctime
        puts file.mtime
  
        # zipping the file
        orig = a[i]
        Zlib::GzipWriter.open('arch_log.gz') do |gz|
          gz.mtime = File.mtime(orig)
          gz.orig_name = orig
          gz.write IO.binread(orig)
        end
        file.close
      end
    end
    File.delete(a[i])
    i = i + 1
  end
  </code></pre>