Imports System.IO
Public Class CompareFiles
Dim filepath1 As String = "FilePath1"
Dim filepath2 As String = "FilePath2"
Private Function Ficheiro(ByVal file1 As String, ByVal file2 As String) As Boolean
Dim ficheiro1 As New FileInfo(file1)
Dim ficheiro2 As New FileInfo(file2)
'File 1 properties
Dim Size1 As Long = ficheiro1.Length
Dim nome1 As String = ficheiro1.Name
Dim dateFile1 As Date = ficheiro1.LastWriteTime
'File 2 properties
Dim Size2 As Long = ficheiro2.Length
Dim nome2 As String = ficheiro1.Name
Dim dateFile2 As Date = ficheiro2.LastWriteTime
'1 Use
If (Size1 = Size2) And (nome1 = nome2) Then
Ficheiro = True
Else
Ficheiro = False
End If
''2 Another Use Compare by datediference'
'If DateDiff("s", dateFile1, dateFile2) = 0 Then
' Ficheiro = True
'Else
' Ficheiro = False
'End If
Return Ficheiro
End Function
'Using ther function
Public Sub UseCompare()
'Check If files exists
If File.Exists(filepath1) And File.Exists(filepath2) Then
If Ficheiro(filepath1, filepath2) = True Then
'Something = Matches ...
Else
'Nothing
End If
Else
'One or another file missing
End If
End Sub
End Class
Sem comentários:
Enviar um comentário