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

W. eWatson wolftracks at invalid.com
Sat Dec 5 05:57:46 EST 2009


I'm trying to store analytic data in a folder called Analysis. If the 
user doesn't have the folder, I make one for him, and then write a txt 
file into it. In this case a histogram of values, x and frequency. 
However, it appears that I made a mistake somewhere and cannot delete it 
using the Win XP delete. Here's the code that determines if Analysis 
exists, and whether to create it.

         print "Path for Histogram", self.current_path
         s = self.current_path
         s = "Analysis"
         s = os.path.join("Analysis",s)
         print "s joined ",s    <------------- debug print
         if not os.path.exists("Analysis"):
             os.mkdir("Analysis")
         f = file( s, "wb")
         if not f:
             self.LogError( "Histogram file creation error 1" )
             return False

In writing the code to handle all of this, I forgot to write the txt 
folder to the file, nor did I close it. It was someone else's code, and 
I got caught up in the creation of Analysis. Here's what XP tells me 
when I try to delete the folder.

Very funny. I just tried it to get the content of the msg, and XP 
deleted it. Let me recreate it and try again. OK, here it is:

   Error Deleting Folder or File.
   Cannot delete Analysis: It is being used by another person or program.
   Close programs that might be using it and try again.

There is no file created, just the folders Analysis\Analysis. One too 
many. The second Analysis shows as an icon for a file of size 0KB.

I printed with the debug print above:
   Path for Histogram Events\v20070206_055012.06.dat
   s joined  Analysis\Analysis
Analysis\Analysis should only be Analysis.



More information about the Python-list mailing list