Can you explain what you are trying to do a little better. What kind of file? Do you just want to open it as a binary file? How many bytes? Anything is possible, the problem is I only have one lifetime.
This is a form of security so that every time when I open the file with my program I can check if the sum of the original file equals the new sum (it could be that the user replaced the file and then renamed it to the origins name). I guess this can be done with any kind of file. I want to eg. sum the first 400 bytes.
If I open it as a binary file? Will I be able to do it then. And if so .. how?
I hope this explained my question a little bit more.
Yes. Open the file for binary access read.
dim an array as byte() and redim it (400)
Use get to read the data directly into the array.
Loop through the array to sum the bytes.
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
If the file is not too big (less than 100k) you can crc the whole thing and verify that checksum with a pre-recorded one. Troy Williams B.Eng.
fenris@hotmail.com
Fenris's probably got a good solution there - I haven't checked it.
I was thinking of something like:
-----------------------------------------------------------
Dim Inf As Byte, D() As Byte, s As Long, i As Long
ReDim D(400)
Inf = FreeFile
Open "c:\tmp\test.txt" For Binary Access Read As #Inf
Get #Inf, , D
Close #Inf
s = 0
For i = 0 To UBound(D)
s = s + D(i)
Next i
MsgBox s
----------------------------------------------------------- Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.