Combining byte arrays and loading in word document

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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();
 
SS madhu said:
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.
 
thank you

Willy Denoyette said:
SS madhu said:
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.
 
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 said:
SS madhu said:
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.
 
Back
Top