473,413 Members | 1,733 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,413 software developers and data experts.

Combining byte arrays and loading in word document

Hi,

I have two word files.
listprice.doc,product.doc
I converted each of the documents into bytes
byte[] bytedata - lisprice.doc
byte[] bytedata1-product.doc
I create a new array and copy both the contents in it and upload it to a
file in d:
I am getting only the lisprice.doc document in D:\File.doc,I am not getting
product.doc.

plz help.

code:

System.Type elementType = byteData.GetType().GetElementType();
byte[] newArray = new byte[byteData.Length + byteData1.Length];
byteData.CopyTo(newArray, 0);
byteData1.CopyTo(newArray, byteData.Length);
string new_str_array = System.Convert.ToBase64String(newArray);
System.IO.FileStream oFileStream;
oFileStream = new System.IO.FileStream(@"D:\File.doc",
System.IO.FileMode.Create);
oFileStream.Write(newArray, 0, newArray.Length - 1);
oFileStream.Close();

Apr 4 '07 #1
3 7880
"SS madhu" <SS*****@discussions.microsoft.comwrote in message
news:2A**********************************@microsof t.com...
Hi,

I have two word files.
listprice.doc,product.doc
I converted each of the documents into bytes
byte[] bytedata - lisprice.doc
byte[] bytedata1-product.doc
I create a new array and copy both the contents in it and upload it to a
file in d:
I am getting only the lisprice.doc document in D:\File.doc,I am not getting
product.doc.

plz help.

code:

System.Type elementType = byteData.GetType().GetElementType();
byte[] newArray = new byte[byteData.Length + byteData1.Length];
byteData.CopyTo(newArray, 0);
byteData1.CopyTo(newArray, byteData.Length);
string new_str_array = System.Convert.ToBase64String(newArray);
System.IO.FileStream oFileStream;
oFileStream = new System.IO.FileStream(@"D:\File.doc",
System.IO.FileMode.Create);
oFileStream.Write(newArray, 0, newArray.Length - 1);
oFileStream.Close();


You can't combine two word documents by simply adding their binary contents, Word files are
specially formatted and their format can change from one version to another, you have to
respect that format when changing their contents. The only sure way to do what you want is
by using the Word automation interface.

Willy.

Apr 4 '07 #2
thank you

"Willy Denoyette [MVP]" wrote:
"SS madhu" <SS*****@discussions.microsoft.comwrote in message
news:2A**********************************@microsof t.com...
Hi,

I have two word files.
listprice.doc,product.doc
I converted each of the documents into bytes
byte[] bytedata - lisprice.doc
byte[] bytedata1-product.doc
I create a new array and copy both the contents in it and upload it to a
file in d:
I am getting only the lisprice.doc document in D:\File.doc,I am not getting
product.doc.

plz help.

code:

System.Type elementType = byteData.GetType().GetElementType();
byte[] newArray = new byte[byteData.Length + byteData1.Length];
byteData.CopyTo(newArray, 0);
byteData1.CopyTo(newArray, byteData.Length);
string new_str_array = System.Convert.ToBase64String(newArray);
System.IO.FileStream oFileStream;
oFileStream = new System.IO.FileStream(@"D:\File.doc",
System.IO.FileMode.Create);
oFileStream.Write(newArray, 0, newArray.Length - 1);
oFileStream.Close();

You can't combine two word documents by simply adding their binary contents, Word files are
specially formatted and their format can change from one version to another, you have to
respect that format when changing their contents. The only sure way to do what you want is
by using the Word automation interface.

Willy.

Apr 4 '07 #3
I would be grateful to u,if u tell me how to go about this.
also,I do not want to create temperory file while doing this merging.

madhu

"Willy Denoyette [MVP]" wrote:
"SS madhu" <SS*****@discussions.microsoft.comwrote in message
news:2A**********************************@microsof t.com...
Hi,

I have two word files.
listprice.doc,product.doc
I converted each of the documents into bytes
byte[] bytedata - lisprice.doc
byte[] bytedata1-product.doc
I create a new array and copy both the contents in it and upload it to a
file in d:
I am getting only the lisprice.doc document in D:\File.doc,I am not getting
product.doc.

plz help.

code:

System.Type elementType = byteData.GetType().GetElementType();
byte[] newArray = new byte[byteData.Length + byteData1.Length];
byteData.CopyTo(newArray, 0);
byteData1.CopyTo(newArray, byteData.Length);
string new_str_array = System.Convert.ToBase64String(newArray);
System.IO.FileStream oFileStream;
oFileStream = new System.IO.FileStream(@"D:\File.doc",
System.IO.FileMode.Create);
oFileStream.Write(newArray, 0, newArray.Length - 1);
oFileStream.Close();

You can't combine two word documents by simply adding their binary contents, Word files are
specially formatted and their format can change from one version to another, you have to
respect that format when changing their contents. The only sure way to do what you want is
by using the Word automation interface.

Willy.

Apr 4 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: alwayswinter | last post by:
I currently have a form where a user can enter results from a genetic test. I also have a pool of summaries that would correspond to different results that a user would enter into the form. I...
16
by: Samuel Thomas | last post by:
Hello Friends, I understand(could be wrong) that the smallest chunk of memory is called a word. If that is correct, that means if I am using a 32 bit OS a word is 4 bytes. So that's why the size...
2
by: Christopher Beltran | last post by:
I am currently trying to replace certain strings, not single characters, with other strings inside a word document which is then sent to a browser as a binary file. Right now, I read in the word...
2
by: Pete Mann | last post by:
Hi, Is there anyway to programmatically load a byte array into a word document in c#? We have an application that streams a byte array of a previously saved word document into a c# client. I...
3
by: tigrrgrr42 | last post by:
I am working(vb.net03and05) with word documents stored in a sql db and I am currently bringing them from a byte array into a temp file to pop into word and make word do its thing as a com object. ...
1
by: ferraro.joseph | last post by:
Hi, I'm querying Salesforce.com via their AJAX toolkit and outputting query results into a table. Currently, their toolkit does not possess the ability to do table joins via their structured...
1
by: agatha.life | last post by:
I did a javascript for the loading of images (I didn't want to have the images loaded in "on loading" because they are too many). The website is for a model and if you look at the codeof pages (...
17
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need...
9
by: Leon_Amirreza | last post by:
How Can I cast a uint type to a byte? Does the following code do this? uint a = 5; byte b = new byte; b = (byte)a;
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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
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...

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.