Why does Isolated storage not delete the last two temporary files when exiting on a Windows Phone 7?

355 Views Asked by At

I have written an application that uses Isolated storage store data that I want to clear out on a periodic basis when it gets old. I have written a function that is called from Closing that checks the isolated storage for old data and deletes it.

This routine will delete everyfile that it is supose too except the last two files in the directory. When I debug the code I can see it execute the DeleteFile method on those files. I even when as far as checking right after the call to DeleteFile to see if the file still exists. According to the debugger it does not.

Yet when the appication starts up again the old data is for those last files is still in isolated storage. Thinking that it may be a race condition I put a Thread.sleep(1000) after the delete routeines.

The phone does not honor this delay and exits immediately after executing the delte code. I could not find a flush command that would be related to DeleteFile as I don't have a reference to a stream at that point.

Has anyone else found this or something similar? Is there a magic flush method I am missing or is this a defect in the phone IsolatedStorage implementation?

1

There are 1 best solutions below

0
On

i agree with Matt and Matthieu. though also wish to ask u have u tried truncating the file? IsolatedStorageFileStream isfStream = new IsolatedStorageFileStream(strXMLFile, FileMode.Truncate, isf);