Imports System.IO

Public Class ClassAllgemeineFunktionen
   
    Public Function func_check_file_use(ByVal filename) As Boolean
        Dim fs As Integer = FreeFile()
        Dim inuse As Boolean = False
        If File.Exists(filename) Then
            Try
                FileOpen(fs, filename, OpenMode.Binary, _
                OpenAccess.ReadWrite, OpenShare.LockReadWrite)
            Catch
                inuse = True
            Finally
                FileClose(fs)
            End Try
        End If
        Return inuse
    End Function
    Public Function Delete_File(originFile As String)
        Try
            If file_exists(originFile, False) = True Then
                System.IO.File.Delete(originFile)
            End If
        Catch ex As Exception
            MsgBox("Fehler in Funktion Delete_File - Fehler: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
        End Try
    End Function

    Public Function file_exists(ByVal _file As String, ByVal suche As Boolean)
        Try
            If System.IO.File.Exists(_file) Then
                Return True
            Else
                Return False
            End If
        Catch ex As Exception
            MsgBox("Fehler in Funktion file_exists - Fehler: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
            Return False
        End Try
    End Function
    

    
   
End Class
