?
Solved

How do I read bytes in a file?

Posted on 2010-11-12
4
Medium Priority
?
968 Views
Last Modified: 2012-05-10
I have my file (it is a QDX file if anyone is familiar with that...) and I need to read the last 4 bits of the 559th byte in this file using vb.net or vbscript.  I've looked at a few other methods on here but can't get any of them to work.  Any help is appreciated!  Thanks
0
Comment
Question by:jasgiv1122
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 34123065
Perhaps this?
Dim value As Short

Using source As New System.IO.FileStream("C:\file\path\file.qdx", IO.FileMode.Open)
	Dim target As Integer
	Dim mask As Short = 15

	source.Seek(559, IO.SeekOrigin.Begin)
	target = source.ReadByte()
	value = target And mask
End Using

Open in new window

0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 34123075
The offset probably needs to be 558 rather than 559.
0
 
LVL 2

Author Comment

by:jasgiv1122
ID: 34124163
This worked perfectly, thanks!  Can you explain the 'mask' part so I can sort of grasp what you did?  Thanks!
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 34125044
The mask is for "and I need to read the last 4 bits". 15 in binary is 0000 1111, and when you AND that value with another value, you get the values of the last four bits.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month12 days, 3 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question