Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Is there a way to use the FileAttributes properties and methods to kill an mdb that is open and locked?

I have a third party library that is clinging to mdb's like they were going out of style. I want to kill the lock and delete the database, regardless of what the application thinks about it. Can I do this?

Right now the only way I can delete the mdb is if I kill the aspnet process from the previous run.

I've looked deeply into releasing all of the COM objects and references to no avail. Now I just want to kill, kill , kill Access files.

Wanna-Be C# Superstar
Posted
Finally
           Marshal.ReleaseComObject(pFWrkSpace)
           Marshal.ReleaseComObject(g)
           Marshal.ReleaseComObject(pWrkSpcFactory)
           Marshal.ReleaseComObject(pFeatureDataset)
           Marshal.ReleaseComObject(pGPMessages)

           g = Nothing
           pFWrkSpace = Nothing
           pWrkSpcFactory = Nothing
           pFeatureDataset = Nothing
           pGPMessages = Nothing

           GC.Collect()
           COMSupport.AOUninitialize.Shutdown()

           Try
               Dim fileIOPerm1 As FileIOPermission
               If File.Exists(Destgdb) Then
                   fileIOPerm1.AddPathList(FileIOPermissionAccess.Write, Destgdb)
                   File.Delete(Destgdb)
               End If

           Catch ex As Exception
               Me.TextBox1.Text &= ex.Message
           End Try

       End Try

Wanna-Be C# Superstar
Posted
I would think that once you kill the 3rd party tool that isn't correctly releasing the database that you could use System.Management to get the open processes and then kill the process from there.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...