如何解决从 .bin 文件中的文本文件中查找特定字符串?
所以我试图找出文本框中列表中的字符串是否存在于 .bin 文件中。如果确实找到它,请提供它的位置。到目前为止,我可以找到一个我自己输入的字符串,但我不知道如何从文本文件中循环字符串,直到找到一个?
Dim j As Integer
Dim i As Integer
Dim ByteBuffer As Byte() = File.ReadAllBytes("C:\Users\PCX\Desktop\ori.bin")
Dim StringBytes As Byte() = Encoding.UTF8.GetBytes("EDC16")
For i = 0 To (ByteBuffer.Length - StringBytes.Length)
If ByteBuffer(i) = StringBytes(0) Then
j = 1
While j < StringBytes.Length AndAlso ByteBuffer(i + j) = StringBytes(j)
j += 1
End While
If j = StringBytes.Length Then
MessageBox.Show("String was found at offset {0}" & CStr(i))
Else
MessageBox.Show("nothing found")
End If
End If
Next
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。