been trying to do this for a few days with not much luck, I found some code when I searched but its not reading 900 chars of the file only the first few characters, heres my code:
BTW its supposed to read the first 900 chars
VB Code:
Dim File As String
Dim fs As FileStream
Dim binRead As BinaryReader
Dim readbuf(900) As Char
Dim i As Integer
Dim strData As String = vbNullString
File = "C:\UK Wholesalers.doc"
fs = New FileStream(File, FileMode.Open, FileAccess.Read, FileShare.None)
That snippet I gave reads a doc (MS word file, but works with any). If you just want the ASCII characters from it, get rid of the GetBinary part. It's passing the ascii value to the function and returning a string to represent it in binary. If you drop it, you'll get numerical data.
I messed with this a little and it turns out Notepad cheats. If the value is EXT (End of Text) or EOT (End of Transmission), it replaces it with a space and continues. Which basically means Notepad turns your executibles into swiss cheese when you're looking at it. If you want to preserve the executible in its original state and read through it, you'll need to use the actual numeric values.
yes I used a doc in my post #1 but by reading the fille for binary access it doesnt matter what file type it is, it should read the raw data, this is how I do it in VB6:
VB Code:
Open strFilename For Binary As #1
strBuffer = Space(LOF(1))
Get #1, , strBuffer
Close #1
and that would open up any filetype and put the raw data (like in my last post example data) into the strBuffer so it can be processed or just displayed.
the screenshot is a hex editor, it shows the file data in hex form, and in text form, thats what I want, to display the text like that in a textbox, i dont want to replace any chars, I know this hex editor replaces nothing with ..... but all i want is the original contents