Reading and writing integers to file in big-endian order

Posted on 2004-10-05
Last Modified: 2008-02-01

I need to read and write integers (4 byte) from/to a file in big-endian order.  What is the best way to change the byte order of an integer in VB.NET?  I am writing a file with unicode strings and that part was easy using the Encoding object with a BinaryReader and BinaryWriter but the integer values are more difficult.

Thanks in advance,
Question by:rkellow
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

Expert Comment

ID: 12232643
big-endian?, the smallest first and the biggest last?

Author Comment

ID: 12232822
The high-order byte first down to the low-order (big-endian).  This is the opposite of how Windows (Intel platforms) store values (little-endian).

Accepted Solution

gregasm earned 500 total points
ID: 12233006
Use the BitConverter class.

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using 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 …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

729 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