Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7442445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:10:34+00:00 2026-05-29T11:10:34+00:00

System: Windows Server 2008 Ruby 192 in ‘delete’: Permission denied Errno:EACCES the line: File.delete(‘filename.ext’)

  • 0

System:

Windows Server 2008
Ruby 192

in ‘delete’: Permission denied Errno:EACCES

the line: File.delete(‘filename.ext’)

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

I was suspecting that file wasn’t closed but it is closed.

Source code:

Dir.foreach(FileUtils.pwd()) do |f|
  a[i] = f
  if a[i].end_with?('log')
    file = File.open(a[i])
    if file.ctime < TIME_TO_REMOVE_LOGS || file.mtime < TIME_TO_REMOVE_LOGS || File.size(a[i]) > 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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:10:35+00:00Added an answer on May 29, 2026 at 11:10 am

    It’s not closed. The file only gets closed sometimes depending on ctime. There’s a lot wrong with your code but the main point is this: be safe with your files and use a block.

    File.open(a[i]) do |file|
      # access file 
    end
    # now you don't need to wonder if it's closed.
    File.delete(a[i])
    

    Also give your variables better names.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a system with windows server 2008 , Apache httpd 2.2 and trac
On Windows Server 2008 R2 the following very simple program behaves different on system
Given a Windows Server 2008 R2 system, where the service accounts use a non-English
I installed Klocwork 9.2.1.7276 on a fresh Windows Server 2008 x86 system. During the
I've got DotNetNuke (v5.1.4 Community Edition) setup on a Windows Server 2008 64-bit system
System is Windows Server 2008 R2 Enterprise 64 bit Running Microsoft SQL Server 2008
The system is using Windows Server 2008 R2 SP1, Tomcat 5.5.28, and Java SE
I have deployed my application on IIS 7.5 on windows server 2008 operating system
I have a Windows Server 2003 system that is used for terminal services. We
I want to set up a SVN Server on a Windows 2003 system. At

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.