473,503 Members | 3,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing specific Byte[] Array to a file

Airslash
221 New Member
Hello,

I'm currently writing a tool to help me to translate a game into English. The game in question is using .PAK files to store all it's resources and information. I've managed to understand how the .PAK files are beeing created, and I already have a tool that is capable of reading through those files like a ZIP program would do.

The .PAK file has a header that consists of the following structure:

- 4 bytes telling the amount of files stored inside.

- repeating pattern:

160 bytes : filename
4 bytes : start position
4 bytes : length
24 bytes : encoding protocol
4 bytes : version

- filedata

As mentioned the reading isn't a problem. But now I want to be able to make my own translated pak file with the same structure. So I assume I read all the files, translate them and then write them back inside the file.

But how can I be sure, that if I translate a filename for example, and wish to write it back in the header, that I actually write out 160 bytes again for the filename, and not more or less bytes. ??



p.s: i hope this question is clear...
Nov 12 '07 #1
7 1889
Plater
7,872 Recognized Expert Expert
What you could try doing maybe, is to make a class called like "PAKFile" that has like:
byte[] filename = new byte[160]

And other things to exactly match the structured parts of the pak files.
Then you just have to populate them with the write info and write it all back out?
Nov 12 '07 #2
Airslash
221 New Member
What you could try doing maybe, is to make a class called like "PAKFile" that has like:
byte[] filename = new byte[160]

And other things to exactly match the structured parts of the pak files.
Then you just have to populate them with the write info and write it all back out?

Ok,

truth be told, I already have such a class written.



i'm sooo stupid for not realising that.....
Nov 13 '07 #3
rajumsoftprof
1 New Member
any one know how to write specific byte array to a file
Nov 13 '07 #4
Plater
7,872 Recognized Expert Expert
Are you planing on overwriting a file or just making a new copy?
Making a new copy is less touchy, but sometimes less usefull.
You should be able to seek in a FileStream I think?
Nov 13 '07 #5
r035198x
13,262 MVP
any one know how to write specific byte array to a file
Have a look at the BinaryWriter class.
Nov 13 '07 #6
Airslash
221 New Member
Are you planing on overwriting a file or just making a new copy?
Making a new copy is less touchy, but sometimes less usefull.
You should be able to seek in a FileStream I think?
it's to make a new file. I don't want to overwrite the existing file because it could destroy the client if it doesn't work properly.
Although its not that important cause I always make a backup before testing on a file.

The basic idea is to sniff in the pak file, translate all the japanese to English, and have a custom pak file to work with, so all text and materials ingame are no longer in Japanese but in English.
Nov 13 '07 #7
Plater
7,872 Recognized Expert Expert
So yeah, create a .WriteToFile(string filename) function on your PakFile class (or somewhere)
and have it write out the bytes in the correct structure
Nov 13 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

10
3246
by: Kristian Nybo | last post by:
Hi, I'm writing a simple image file exporter as part of a school project. To implement my image format of choice I need to work with big-endian bytes, where 'byte' of course means '8 bits', not...
5
4329
by: zambak | last post by:
Hi I have assignment for some wierd compression alghoritam that will read in from a file convert characters to 5 bit codes and then write out compressed version of the original file. For...
2
7791
by: phyzics | last post by:
I am porting an application from C++ to C#, and am having trouble finding a way to quickly and efficiently write structures to a binary file. In C++ this is trivial because all that is necessary is...
2
6839
by: melanieab | last post by:
Hi, I'm trying to store all of my data into one file (there're about 140 things to keep track of). I have no problem reading a specific string from the array file, but I wasn't sure how to...
4
16903
by: Gidi | last post by:
Hi, i have a byte array, and i'm writing it to a file, i want to start a new line, how can i do it? (like WriteLine in StreamWriter) I'm using FileStream: FileStream fs = new...
2
6768
by: simonc | last post by:
Is there an easy way of writing a number in 32 bit integer format into four bytes of a file? I am experimenting with FilePut but I can only make it work by defining a four byte array and doing some...
0
2244
by: bohuge | last post by:
Hey! At the time being I'm working on a backup solution for a Qtek9090 pocketpc, which should be able to find and backup outlook data to a server, local files, messages and contact from the sim...
2
3028
by: Craig | last post by:
I have the need to write a byte of information to a specific location in a text file. eg. the file looks something like this. FYYNN Line 1 Line 2 <eof>
3
2503
by: Rich Shepard | last post by:
I need to learn how to process a byte stream from a form reader where each pair of bytes has meaning according to lookup dictionaries, then use the values to build an array of rows inserted into a...
6
1585
by: John | last post by:
Hi I am trying to save settings of controls on my form to a file so I can read them back later and recreate the controls on the form. I have figured out how to go through all controls and get...
0
7192
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7445
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4991
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4665
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
369
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.