I want to terminate an application using the full file path via vb.net,so i am using this code snippet
Public Sub forceCopy()
        Try
            'Dim strDatabasePath As String = My.Computer.FileSystem.CombinePath(Application.UserAppDataPath, "LIC.mdf")
            'Dim strdbLogPath As String = My.Computer.FileSystem.CombinePath(Application.UserAppDataPath, "LIC_log.ldf")
            Dim strDatabasePath As String = My.Computer.FileSystem.CombinePath(My.Application.Info.DirectoryPath, "LIC.mdf")
            Dim strdbLogPath As String = My.Computer.FileSystem.CombinePath(My.Application.Info.DirectoryPath, "LIC_log.ldf")
            Dim path As String = My.Computer.FileSystem.CombinePath(My.Application.Info.DirectoryPath, "LIC.mdf")
            Dim matchingProcesses = New List(Of Process)
            For Each process As Process In process.GetProcesses()
                For Each m As ProcessModule In process.Modules
                    If String.Compare(m.FileName, path, StringComparison.InvariantCultureIgnoreCase) = 0 Then
                        matchingProcesses.Add(process)
                        Exit For
                    End If
                Next
            Next
            For Each p As Process In matchingProcesses
                p.Kill()
            Next
            My.Computer.FileSystem.CopyFile(strDatabasePath, "c:\backup\LIC.mdf", True)
            My.Computer.FileSystem.CopyFile(strdbLogPath, "c:\backup\LIC_log.ldf", True)
            MessageBox.Show("Backup taken successfully")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
I get an exception "Access Is Denied" .Any idea why?
EDIT: I get the error at this line : For Each m As ProcessModule In process.Modules
 
     
     
     
    