Why Can't I Delete a File I Created with Win XP?

Stephen Hansen apt.shansen at gmail.com
Sat Dec 5 22:19:00 EST 2009


On Sat, Dec 5, 2009 at 6:20 PM, W. eWatson <wolftracks at invalid.com> wrote:

> I'm trying to do a very simple thing. I go to the Analysis folder, and try
> to use Win XP Pro to delete the empty and unnamed file in it. One just does
> a right-click on the empty file, and then uses Delete. It won't let me
> delete it. If I back up to the folder level, it won't let me delete the
> folder, since it's not empty. See the post I made to J moments ago.
>
>
As has been said by various people: you have to close the file in the code.

You aren't doing so, so you can't go delete the file.

There's really nothing at all to this otherwise-- this isn't really even a
python thing. In windows, as long as a file is held open, you can't delete a
file. When a program closes it almost always ends up automatically closing
all the files it had open-- so if you're not seeing that, the program is not
being closed (or it launched another program which inherited the file
handles). You can go manually use task manager to kill any program which
might be holding a handle, or if you don't know which-- log off and log back
on will almost certainly get them all. Failing that, reboot.

There's really nothing to this. Close the file when you're done using it,
and you'll be able to delete it fine.

--S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091205/aa1bc439/attachment-0001.html>


More information about the Python-list mailing list