Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

This sounds like the classic "in-use" problem. Even if the process doing the deletion doesn't have the directory to be deleted as one of it current directories-- every process has a current directory for each logical drive visible to it!--if any other process in the system is using that directory, directly or indirectly, then permission to delete that directory will be denied.

As a simple example: Say you have a system with 2 drive C: & D:, the directory your trying to delete is d:\foo. You have a shell window running, and at some point you switch to the d: drive and cd to \foo....then you switch back to the c: to run the script to delete d:\foo. You get permission denied.

Even though you are running the script at the C:\perl prompt, that shell session still has a handle to d:\foo, and so the system won't let you delete it. Right or wrong, that is the way the system works, and you have to work within that constraint.

The one that usually catches me out is when I have edited a file in the target directory tree and even though I have closed the file, the file dialog retains the last directory I visited as the default location for the next time I want to open a file. So, even though I have no file open in that directory, the file dialog retains a handle to it, and I am prevented from deleting it until I either close the editor, or bring up the file dialog and switch to a different directory.

The really horrible bit is that there are many file dialogs in the system, and each retains it's own sense of the CWD. It can be a real pain working out what and where the open handle is being retained.

I'm sorry, but I don't have a solution to this, just a logical (if neither official nor what you want to hear) explanantion.

The explorer seems to have some special logic built in so that if you right-click delete a subtree, the root directory of that subtree, which you made a CWD when you highlighted it, doesn't disappear until you move to another location, and it then is deleted. Something similar to the unix "mark for deletion" process. Unfortunately, this seems to a be a property of the explorer, rather than the underlying OS, and worse, even the explorer doesn't seem to be able to get it right all the time.

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail

In reply to Re: Re: Re: rmtree deletes everything inside the folder but doesn't deletes the root folder him self by BrowserUk
in thread rmtree deletes everything inside the folder but doesn't deletes the root folder him self by Nelly

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2023-06-07 09:40 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (29 votes). Check out past polls.