Jump to content

Remove and create directory


Recommended Posts

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 by SublimePorte
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...