473,386 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to append two binary files

38
Hi

I have got two binary files.(extension is .atf (some IBM stuff)). Dont know the exact details.I think the files are something like PDF files.i just want to append two files.

I am thinking of doing like:

1. Convert file1.atf to byte array

2. Convert file2.atf to byte array

3. Combine two

Is this possibile? Also can I convert the new byte array back to ATF format?



Guys any hint or clue....?



Thanks in advance,

jaleel
Oct 11 '07 #1
3 4204
Shashi Sadasivan
1,435 Expert 1GB
If its bits and bytes then it dosent matter about the extension.

So after making changes you can give it the extension name and it will work fine.

try reading one file into bytes and storing it to a new file. should work without problems

However while merging, you would have to take a look at the format of that atf extension.

you might need to do some changes.
if it was a text file, you could have got away from it, but if it is filled with presentational information, you will need to merge it accordingly.

cheers

Found a link which explains the atf format structure.

good luck
Oct 11 '07 #2
jaleel
38
Actually I a m creating .atf file from a word file using an atf print driver. Then I want combine two atf files into one.

From another forum I got a code block like this
Expand|Select|Wrap|Line Numbers
  1. using(BinaryWriter writer = new BinaryWriter(File.OpenForWriting(<path>))
  2. {
  3.  
  4.    //Skip to end
  5.  
  6.    writer.Seek(0, SeekOrigin.End);
  7.  
  8.  
  9.  
  10.    using(BinaryReader reader = new BinaryReader(File.OpenForReading(<path>))
  11.    {
  12.  
  13.       byte[] buffer = new byte[1024];
  14.  
  15.       while(reader.Position < reader.Length)
  16.  
  17.       {
  18.  
  19.          int count = reader.Read(buffer, 0, buffer.Length);
  20.          writer.Write(buffer, 0, count);
  21.  
  22.       };
  23.  
  24.    };
  25. };
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
But here I dont know how to get reader.Position and reader.Length. I am in search of it.There are no properties like that..cud u pls help me...?
Oct 11 '07 #3
jaleel
38
Hi ,

Now I am able to append two .afp files using FileStream itself.Actually when I went thru a document pointed by Shashi , I found .afp is a text file format.
So I just tried using FileStream class. Now it works like charm. Thank u Shashi.....:)
The code is like this
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.             Using fs As New FileStream(sourceFile, FileMode.Append, FileAccess.Write)
  4.  
  5.                 Dim buffer() As Byte = File.ReadAllBytes(appendFile)
  6.  
  7.                 fs.Write(buffer, 0, buffer.Length)
  8.  
  9.             End Using
  10.  

Thanks again to Shashi
Oct 12 '07 #4

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

Similar topics

8
by: b83503104 | last post by:
Hi, I want to append one (huge) file to another (huge) file. The current way I'm doing it is to do something like: infile = open (infilename, 'r') filestr = infile.read() outfile =...
2
by: vbMark | last post by:
Greetings, This seems like it should be simple but I can't figure out how to do this. I just want to append binary file 2 on to the end of binary file 1. Sample code please? Thanks!
0
by: Mad Scientist Jr | last post by:
can someone post code on how to * merge 2 mono wav files into a single stereo wav file (one file in the left channel one in the right) * append one wav file to another * merge 2 stereo wav...
10
by: joelagnel | last post by:
hi friends, i've been having this confusion for about a year, i want to know the exact difference between text and binary files. using the fwrite function in c, i wrote 2 bytes of integers in...
2
by: ashwini.chaturvedi | last post by:
hi frnds, can anyone tell me how to append record/records in a binary file in vb.net thax
68
by: vim | last post by:
hello everybody Plz tell the differance between binary file and ascii file............... Thanks in advance vim
3
by: Freddy Coal | last post by:
Hi, I would like append strings to a binary file, but I donīt understand how make that. I try with: FileOpen(1, Folder_Trabajo & "\Toma_Trazas.FC", OpenMode.Append, OpenAccess.Write,...
4
by: BerlinBrown | last post by:
Is it possible to just build the binary content of a zip file. I want to create the content in memory (e.g. return binary data) and then get those byte strings representing the zip file? Is that...
2
by: kvnil | last post by:
Cheers, I've been struggling all day today with this, maybe you could give me some useful pointers. I would like to (elegantly) concatenate a string out of all node values in a map. I have to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.