|
-
Feb 4th, 2008, 12:57 AM
#1
Thread Starter
New Member
Load & Display a binary file
I would like to load a binary file, display its contents, and even edit them.
My knowledge is very limited as i'm just learning basic programing.
If someone can help i would greatly appericate it. I konw i will have many questions so please be patient with me.
Assumed: Once the file is loaded and parsed i will know how to break down the data. I understand the file structure, and have worked with this particular file for a long time. Currently when doing this, i just use a hex editor. However this would be a leap forward for me.
You may wonder: Yes i have a map editor for this. But the original programmer is a lazy &%&(^ and i want to get it done.
File Linkage: Items File
-
Feb 4th, 2008, 05:06 AM
#2
Re: Load & Display a binary file
Care to explain the format of this file?
IO.File.ReadAllBytes will get the entire contents into a Byte array, which you can then manipulate as you like.
The BinaryReader class allows you to read binary primitives from a file.
-
Feb 4th, 2008, 08:50 PM
#3
Thread Starter
New Member
Re: Load & Display a binary file
Well 
The first 738 bits are the first item. This is our default item that appears when ever the game / server does not understand the item number presented to its self.
Line 739 is where item 1 starts.
The Next 28 bits are item1.language1.item name, set.length = 28 bits
next 12 bits are blank
Starting at bit 778
The next 28 bits are item1.language2, set.length = 28 bits
next 15 bits are blank
Starting at bit 818
256 bits are item1.language1.item description, set.length = 256bits
Starting at bit 1074
256 bits are item1.language2.item description, set.length = 256bits
The remaining 146 bits are broken up in sets of 1 and 2 bit lengths. Maybe your question was not aimed at this information so i wont post it in case.
After the last 146 bits, the next item starts.
Last edited by enuro12; Feb 4th, 2008 at 08:55 PM.
-
Feb 4th, 2008, 09:30 PM
#4
Re: Load & Display a binary file
When you say "bits", do you actually mean "bytes"?
Sounds like a job for the BinaryReader to me.
-
Feb 4th, 2008, 09:33 PM
#5
Thread Starter
New Member
Re: Load & Display a binary file
Sorry extremely long few weeks. Yes bytes.
I suppose this could be to big of a project to start with. =\
-
Feb 4th, 2008, 09:41 PM
#6
Re: Load & Display a binary file
This part in particular is not really a big deal. You can just create a BinaryReader something like this:
vb.net Code:
Using reader As New IO.BinaryReader(IO.File.OpenRead("file path here")) 'Read file here. End Using
and inside the Using block you call methods like ReadChars and ReadInt32.
Note that if you want to read text that is not prefixed with its length then you need to call ReadChars, NOT ReadString, and then convert the Char array returned to a String.
Last edited by jmcilhinney; Feb 4th, 2008 at 09:46 PM.
-
Feb 4th, 2008, 11:45 PM
#7
Thread Starter
New Member
Re: Load & Display a binary file
Any chance you have some example code & resources i can use? Thanks for the help!
-
Feb 4th, 2008, 11:47 PM
#8
Re: Load & Display a binary file
You can use the MSDN Library, as can everyone. You access it using the Help menu in your IDE.
-
Feb 4th, 2008, 11:54 PM
#9
Thread Starter
New Member
Re: Load & Display a binary file
Thats the reply i expected. If i could understand the MSDN library i wouldnt be on this forum. =\ back to the grind.
-
Feb 5th, 2008, 12:10 AM
#10
Re: Load & Display a binary file
I don't really know what you expect. You know that you have to use a BinaryReader. I've shown you how to create one. I've told you that you need to call methods like ReadChars to read characters and ReadInt32 to read an integer. MSDN provides code examples. What exactly is it that you don't understand? If there's a specific issue then tell us what it is. Otherwise it just sounds like you want it done for you. I'm not saying that you necessarily do but if you've already got a resource that describes each method and provides a code examples of how to use them then what else is there?
-
Feb 5th, 2008, 12:37 AM
#11
Thread Starter
New Member
Re: Load & Display a binary file
Well to someone who understands these examples i can understand how it would benifit them. But this is like me saying i want to make a website, that people can load edit and save data. And the answer being you need <html> and </html> you'll need <body> and <Form> you'll want to save that to a file or send it to your mysql database to. Good Luck!
How about just a tutorial somewhere specifically related to binary files? I've read and completed all the crap in the "visual basic 2005 book" and "advanced visual basic 2005" from the local college.
These books only covered 1 file save, and then jumped straight to MSSQL and web dev. Neither of which are any hlep to me.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|