SublimePorte Posted May 18, 2010 Posted May 18, 2010 (edited) Hi, I am trying to remove a directory, and then re-create it. The directory has about 300mb of data in it, and for some reason it won't fully delete until the script finishes executing, which therefore means re-creating the directory is impossible. If FileExists($dbpath) Then If Not DirRemove($dbpath, 1) Then WriteToLog("Could not remove database directory") Return EndIf EndIf ;Sleep(3000) If Not DirCreate($dbpath) Then WriteToLog("Could not create database directory") Return EndIf Edited May 18, 2010 by SublimePorte
hawky358 Posted May 18, 2010 Posted May 18, 2010 That should work fine. The only thing that would prevent the removal is an open file within the path. Since it deletes when your script ends, check if your script doesn't have an open filehandle when you're trying to delete the folder.
SublimePorte Posted May 18, 2010 Author Posted May 18, 2010 Well there is an mssql database in the path, but some code is run to detach it beforehand. And a further check is done to make sure no database in the path is attached. As soon as I terminate the script, the deleted folder disappears, but so long as the script remains open, the folder will not disappear, and is unusable in explorer (and other file managers), it's like the script itself is putting a lock on the files, and doesn't release them or flsuh the delete operation until the script ends. It's very strange behaviour.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now