Posted on 1998-07-07
In my application there are a series of directories creates, in which data is stored.
As the data is processed, it is moved over to a file server (from within the application) and the directories are to be deleted. To make sure that the directories are empty, I created a function which will delete all files matching a filter (i.e. \MYDATA\SRC\*.*). I know that this delete function works, because when I look at the directory it is empty. The problem lies in the RemoveDirectory function. It will not delete the directory and returns a system code of 32 (The process cannot access the file because it is being used by another process. -> ERROR_SHARING_VIOLATION). Is this just a problem with my code, or is this a common event? Note: I call the DeleteFiles function immediately before I attempt RemoveDirectory. I thought that since I was accessing the directory so soon before I attempted to remove it, that the system would not be updated with its lack-of-file status. However I am not %100 sure about this.