viernes, 21 de junio de 2019

archivo bloqueado


Dim ok As Boolean = file_is_lock(New FileInfo(archivo))


Public Function file_is_lock(ByVal f As FileInfo) As Boolean
        Dim stream As FileStream = Nothing
        Try
            stream = f.Open(FileMode.Open, FileAccess.Read, FileShare.None)
        Catch ex As Exception
            Return True
        Finally
            If Not stream Is Nothing Then
                stream.Close()
            End If
        End Try
        Return False
    End Function

No hay comentarios.:

Publicar un comentario