我有检查这两个文件是否相似的功能。所以我做的一件事就是比较文件的大小。我正在寻找一种比较文件内容并获得匹配百分比的方法。根据百分比值,我可以决定它们是否大致相等?
如果是文本文件,我正在阅读文本并计算差异。但是如果它是excel或任何其他具有类似图像的文件呢?
答案 0 :(得分:0)
您可以尝试这样的事情,然后根据2个文件的比较做出决定。
Imports System.IO
Public Class FileSizeChecker
Public Sub FileChecker()
Dim info As New FileInfo("test.txt")
' Get length of the file.
Dim length As Long = info.Length
' Add more characters to the file.
File.AppendAllText("test.txt", " More characters.")
' Get another file info.
' ... Then get the length.
Dim info2 As New FileInfo("test.txt")
Dim length2 As Long = info2.Length
' Show how the size changed.
Console.WriteLine("Before and after: {0}, {1}", length, length2)
Console.WriteLine("Size increase: {0}", length2 - length)
End Sub