School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
You're Browsing As A Guest! Register Now...
Become an Expert!

Join 357,969 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,563 people online right now.Registration is fast and FREE... Join Now!



Reading library file error

52 Weeks of Code Challenge: Android

Week #11 of the 52 Weeks of Code Challenge is Android, you should give it a shot. Click Here!

Reading library file error Rate Topic: -----

#1 nedoryuk  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-April 09


Dream Kudos: 0

Posted 05 April 2009 - 06:07 AM

Hello. everyone..
I have a problem and need help...
I tried read library file (aaa.lib) with my code.
But I got error when one of files was read.
My code read any other files, so code is no problem.
But I could read it with another C++ code .....;;;$%#
That is why I could not solve this problem..

Detail symtom is that...
From 433th data is totally different with real lib data.
If I change something after 433th data, nothing works.
If I deleted datas 0 ~ 433th in aaa.lib, I got error at another part.

Is there any.. .NET framework problem...???
If you have similar problem, please give me advice...

   FileStream strReadFile = new FileStream(_path + "\\aaa.lib", FileMode.Open);					   
			BinaryReader bReadFile = new BinaryReader(strReadFile);
		   
			int i = 0;
			int nCnt, nNum;

			do
			{
				tmpData_Table.data_no[i] = ByteSwap(bReadFile.ReadUInt32());
				tmpData_Table.data_type[i] = ByteSwap(bReadFile.ReadUInt32());
				tmpData_Table.stuff_type[i] = ByteSwap(bReadFile.ReadUInt32());
			   ....
  } while (++i < (strReadFile.Length / 516));


and this is code for Byte Order

 public uint ByteSwap(uint i_nChangeByteOrder)
		{
			uint nCounterByte = 0x0;
			uint nReturnValue = 0x0;

			for (int nShift = 31; nShift >= 0; --nShift)
				nCounterByte |= (((i_nChangeByteOrder >> nShift) & 0x1) << (31 - nShift));

			nCounterByte = ((nCounterByte & 0x0F0F0F0F) << 4) | ((nCounterByte & 0xF0F0F0F0) >> 4);

			for (int nShift = 24; nShift >= 0; nShift -= 8)
				nReturnValue |= (ChangeByteSwap((nCounterByte >> nShift) & 0xFF) << nShift);

			return nReturnValue;
		}
			   public uint ChangeByteSwap(uint i_cChangeOneByte)
		{
			uint nLowByte = 0x0;
			uint nHighByte = 0x0;

			for (int nShift = 3; nShift >= 0; --nShift)
				nLowByte |= (((i_cChangeOneByte >> nShift) & 0x1) << (3 - nShift));
			for (int nShift = 7; nShift >= 4; --nShift)
				nHighByte |= (((i_cChangeOneByte >> nShift) & 0x1) << (7 - nShift));

			return ((nHighByte << 4) | nLowByte) & 0xFF;
		}

This post has been edited by nedoryuk: 05 April 2009 - 06:10 AM

Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month