renaming an open file in nt like unix?

aaron.watters at gmail.com aaron.watters at gmail.com
Wed Jul 25 14:16:45 CEST 2007


On Jul 13, 2:44 pm, Steve Holden <st... at holdenweb.com> wrote:
> Thomas Heller wrote:
> > aaron.watt... at gmail.com schrieb:=
>
> >> ...Do the NT file systems support [renaming an open file] (which I think is
> >> standard for POSIX systems)?
>
> > Yes, you can do that.  We implemented something like this to replace
> > dlls there are currently in use...
>
> You do have to be careful though, because sometimes Windows refuses to
> let you rename a file because it's in use.

At least on my laptop I see Steve's behaviour. fwiw:

C:\Documents and Settings\aaron\Desktop>opentest.py rename
rename sleeps 1
renamer sleeping 5
now renaming
Traceback (most recent call last):
  File "C:\Documents and Settings\aaron\Desktop\opentest.py", line 69,
in <modul
e>
    renameProcess()
  File "C:\Documents and Settings\aaron\Desktop\opentest.py", line 31,
in rename
Process
    os.rename(firstname, secondname)
WindowsError: [Error 13] The process cannot access the file because it
is being
used by another process

So it looks like the answer in general is "no: you can't do that
on Windows."

Drat! Foiled again.
   -- Aaron Watters

===
Is a bear catholic?
Does the Pope ...?




More information about the Python-list mailing list