Cannot Delete a File?

  • Thread starter Thread starter W. eWatson
  • Start date Start date
W

W. eWatson

I wrote a Python program that creates a folder with a file in it.
Unfortunately, I did not close the file. Further, the file was empty.
When I tried to delete via XP menu for the file, XP objected on the
grounds the file was being used somewhere else.

I suspect that some process was using within Python to execute the
program was alive and still had a grip on the file.

I did manage to delete the derelict file once. It was after I had
rebooted.

How does ibe generally get out of this? I've had this sort of thing
happen before when I was trying to rename a file, and XP objected for
the reason above. If I continued with other matters, I've found I could
return and delete it.
 
W. eWatson said:
I wrote a Python program that creates a folder with a file in it.
Unfortunately, I did not close the file. Further, the file was empty. When
I tried to delete via XP menu for the file, XP objected on the grounds the
file was being used somewhere else.

I suspect that some process was using within Python to execute the program
was alive and still had a grip on the file.

I did manage to delete the derelict file once. It was after I had
rebooted.

How does ibe generally get out of this? I've had this sort of thing happen
before when I was trying to rename a file, and XP objected for the reason
above. If I continued with other matters, I've found I could return and
delete it.


I use this when needed.

Unlocker:
http://ccollomb.free.fr/unlocker/
 
I wrote a Python program that creates a folder with a file in it.
Unfortunately, I did not close the file. Further, the file was empty.
When I tried to delete via XP menu for the file, XP objected on the
grounds the file was being used somewhere else.

I suspect that some process was using within Python to execute the
program was alive and still had a grip on the file.

I did manage to delete the derelict file once. It was after I had
rebooted.

How does ibe generally get out of this? I've had this sort of thing
happen before when I was trying to rename a file, and XP objected for
the reason above. If I continued with other matters, I've found I could
return and delete it.

Windows has had (since Win95) "protections" to prevent
your deleting any file currently loaded. DOS and CMD.EXE
are not limited by these protections, thus can delete any
named file.
 
All the program Bruce mentioned tries to close the file handles, but will
often fail because it cannot drop some dependancies

With your Python program you need to close the file & destroy the new object
to free up memory because keep running it will casuse the machine to tun out
of memory & make the machine unstable
 
Don said:
Windows has had (since Win95) "protections" to prevent
your deleting any file currently loaded. DOS and CMD.EXE
are not limited by these protections, thus can delete any
named file.
I drilled down to the folder that has the trouble via cmd window. When I
use DIR, I see:
date time <DIR> .
date time <DIR> ..
date time 0 Analysis
1 File(s) 0 bytes
2 Dir(s) 26...Gigs
Analysis is the folder I created. The file I created has no name and is
empty. I didn't bother to copy date and time.
I'm not really handy with cmd line, so I was unsuccessful copying to
here. I tried del *, but the dir results above went unchanged.
 
SPAMCOP said:
All the program Bruce mentioned tries to close the file handles, but
will often fail because it cannot drop some dependancies

With your Python program you need to close the file & destroy the new
object to free up memory because keep running it will casuse the machine
to tun out of memory & make the machine unstable
See my post moments ago. I tried cmd window and could not delete the
nameless file. I backed up to the folder level, .../Analysis and tried
to delete the folder. It gave me the folder is not empty.

Probably if I reboot, the file&folder will be released, and I can delete
them as I mentioned. I can then re-run the Python program with a real
file to write.
 
I corrected the Python program and it writes and closes the file
successfully. Getting rid of the erroneous folder and file should be
easy once I reboot.
 
Back
Top