BInary Reader for File Header
BInary Reader for File Header
BInary Reader for File Header
BInary Reader for File Header
BInary Reader for File Header
BInary Reader for File Header BInary Reader for File Header BInary Reader for File Header BInary Reader for File Header BInary Reader for File Header BInary Reader for File Header BInary Reader for File Header BInary Reader for File Header
BInary Reader for File Header BInary Reader for File Header
BInary Reader for File Header
Go Back  Xtreme Visual Basic Talk > > > BInary Reader for File Header


Reply
 
Thread Tools Display Modes
  #1  
Old 10-23-2011, 01:28 AM
thexplanet thexplanet is offline
Newcomer
 
Join Date: Oct 2011
Posts: 1
Default BInary Reader for File Header


Hello all,

I am newbie, and trying to learn.

however, I am stuck at BinaryReader.
actually this is what i am trying to acheive through VB.NET.

say for the following file type :
JPG file = FF D8 FF E0
BMP file = 42 4D BE 4E
PNG file = 89 50 4E 47
GIF file = 47 49 46 38

the above are the 4-byte headers in Hex(raw)

I need to read these headers of any given file using OpenFileDialog using Button1_click event,

on selection of any given file(*.* filters ON)
it should use the BinaryReader and look for only 4-bytes starting from offset 0, and it should not go to EOF marker (-1).

and have a variable to hold this 4-byte header value, to run this in a database table which will check the same header value in the table and would display the corresponding extension of the file. from the table.

I can do this using case, if then...etc.
however, I have to do it using Database and also i need to check for testing purpose to use MsgBox() to display this variable which is holding the 4-byte header.
however, the MsgBox doesnt allow anything other than String.

PS: I tried studying the methods like:
FileOpen/Seek/Peek/ReadBytes().
but still not sure how to get them work.

Can anyone please enlighten me.
I am a Forensic Investigator, but Not a coder.

Thanks in advance.
Reply With Quote
  #2  
Old 10-23-2011, 08:00 AM
OnErr0r's Avatar
OnErr0rBInary Reader for File Header OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,774
Default

Have you considered using BinaryReader.ReadInt32 and then ToString("X8") for the MessageBox?
__________________
Quis custodiet ipsos custodues.
Reply With Quote
  #3  
Old 10-23-2011, 08:13 AM
OnErr0r's Avatar
OnErr0rBInary Reader for File Header OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,774
Default

Btw, a bitmap is only guaranteed to match the first two bytes. Namely: BM

After that is the filesize, which varies.

I think your JPG assumption is also wrong, as only the first two bytes are guaranteed to be the same.
__________________
Quis custodiet ipsos custodues.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
BInary Reader for File Header
BInary Reader for File Header
BInary Reader for File Header BInary Reader for File Header
BInary Reader for File Header
BInary Reader for File Header
BInary Reader for File Header BInary Reader for File Header BInary Reader for File Header BInary Reader for File Header BInary Reader for File Header BInary Reader for File Header BInary Reader for File Header
BInary Reader for File Header
BInary Reader for File Header
 
BInary Reader for File Header
BInary Reader for File Header
 
-->