Deleting Directories with ASP.NET (VB)
-
Does anybody know why ASP.NET (VB) will not delete a directory using the following code: Protected Sub removeDirByForceX(ByVal dirX As String, ByVal errorX As String) ' This deletes a directory, after copying a dummy file in it. ' Without at least 1 file in the directory it does NOT work! ' It is assumed that the calling program has ensured that dirX exists. ' The directory to be deleted is in the application folder. ' The routine is called from an ASP.NET application. ' Although the directory is deleted, all variables/sessions are lost ' and of course the screen freezes! Dim dirX_FP As String = Server.MapPath(dirX) FileCopy(aDummyFile, dirX_FP & "/000-Dummy-file.txt") Try Directory.Delete(dirX_FP, True) Catch ex As Exception errorX = "ERROR: " & ex.Message.ToString Exit Sub End Try errorX = "" End Sub