- I have created a temporary file.
- Added some data to the file created.
- Saved it and then trying to delete it.
But I am getting WindowsError
. I have closed the file after editing it. How do I check which other process is accessing the file.
C:\Documents and Settings\Administrator>python
Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tempfile
>>> __, filename = tempfile.mkstemp()
>>> print filename
c:\docume~1\admini~1\locals~1\temp\tmpm5clkb
>>> fptr = open(filename, "wb")
>>> fptr.write("Hello World!")
>>> fptr.close()
>>> import os
>>> os.remove(filename)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
WindowsError: [Error 32] The process cannot access the file because it is being used by
another process: 'c:\\docume~1\\admini~1\\locals~1\\temp\\tmpm5clkb'